Application Scenarios:
A child window is created under the main window as a member, and when clicked on a button in the Subwindow, the main window receives its signal and handles it.
Example:
child window class:
#ifndef Update_view_h#define update_view_h#include "ui_update_subwindows.h"#include <QtGui/QMainWindow>Class Updateview: Publicqmainwindow{Q_objectPrivate: Ui_update::update_mainwindow Ui; Public:Updateview(qwidget* parent =0, Qt::wflags flags =0); ~updateview (); Signals:voidUp_select_update_file (Qpushbutton *);PrivateSlotsvoid Emit_select_button();};#endif //
#include "UpdateView.h"UpdateView::UpdateView(QWidget* parent,Qt::WFlags flags) : QMainWindow(parent,flags){ ui.setupUi(this); connect(ui.pushButton,SIGNAL(clicked()),this,SLOT(emit_select_button())):: ~UpdateView(){}void UpdateView::emit_select_button(){ emit up_select_update_file(ui.pushButton);}
Main Window signal Slot
void export_da::update_da(){ update_view = new UpdateView(this); connect(update_view,SIGNAL(up_select_update_file(QPushButton*)),this,SLOT(select_update_file(QPushButton*))); update_view->show();}
Here's update_view even though my subwindow, and the signal function that it sends Up_select_update_file is the qpushbutton* type, the realization is that I want to pass the button of the child window to the main window, and use the contents of the main window to set this button.
void export_da::select_update_file(QPushButton* update_file){ = QFileDialog::getOpenFileName(this,tr("Save File"),".",tr("TEXT files (.txt)")); update_file->setText(update_file_name);}
Signal transfer between Qt windows