PDA

View Full Version : 'X' button signal



gib
26th March 2013, 02:46
How do I catch the signal from the main application 'X' button, used to terminate the application?

giblit
26th March 2013, 02:59
on your header add these:

class QPushButton;
private slots: xButtonPressed();
private: QPushButton *x;
and then on you c++ file add this.

connect(xButton,SIGNAL(clicked()),this,xButtonPres sed()));
MainWindowName::xButtonPressed(){
//app close function
}

ChrisW67
26th March 2013, 05:05
How do I catch the signal from the main application 'X' button
You don't, it doesn't emit a Qt signal. You can intercept the closing of your program by re-implementing the QWidget::closeEvent() of your top level widget class.

anwar.qt
26th March 2013, 12:20
I hope you are talking about close (X) button at right hand side of title bar of the window. If it is so then.

Yes totally.. It doesn't emit any signal. There is closeEvent() of QWidget either you have to re-implement it, otherwise you can try using event filters.