PDA

View Full Version : How to close QMainWindow by itself



bagusflyer
1st August 2010, 16:22
I'm trying to use close() function to close my QMainWindow object which is the only window opened. But failed. It did triggered the QCloseEvent just like I pressed X button. I don't know why? Can anybody advise? Thanks

ChrisW67
2nd August 2010, 02:45
It sent a QCloseEvent because that's what it is meant to do.

How did it fail?
What does QWidget::close() return?
If you are providing your own QWidget::closeEvent() handler then make sure it is QEvent::accept()-ing the event.