Hello, I have a problem. I have a MainWindow, and I want hand event when user click close button on MainWindow (x-button). What I should do?
Hello, I have a problem. I have a MainWindow, and I want hand event when user click close button on MainWindow (x-button). What I should do?
in your mainwindow, implement closevent(...).
http://doc.qt.nokia.com/latest/qwidget.html#closeEvent
If you haven't already, you will need to subclass QMainWindow so that you can implement the method.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.
I try implement function closeEvent, but my Window still close! Help me!
Qt Code:
{ event->ignore(); qDebug()<<"Can't close Window"; }To copy to clipboard, switch view to plain text mode
Have you defined the method correctly in your header file?
Qt Code:
protected:To copy to clipboard, switch view to plain text mode
And Importantly, does it inherit from QWidget etc etc.
Please pay attention to my sig. cut and paste a complete example, otherwise you are making everybody guess!
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.
Bookmarks