How do I catch the signal from the main application 'X' button, used to terminate the application?
How do I catch the signal from the main application 'X' button, used to terminate the application?
on your header add these:
and then on you c++ file add this.Qt Code:
class QPushButton; private slots: xButtonPressed();To copy to clipboard, switch view to plain text mode
Qt Code:
connect(xButton,SIGNAL(clicked()),this,xButtonPressed())); MainWindowName::xButtonPressed(){ //app close function }To copy to clipboard, switch view to plain text mode
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.How do I catch the signal from the main application 'X' button
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.
Bookmarks