Is it possible to keep a QWidget
open after close button clicked? Suppose that widget is main widget. i.e. not child of another widget.
Detailed Description. Close events are sent to widgets that the user wants to close, usually by choosing "Close" from the window menu, or by clicking the X title bar button. They are also sent when you call QWidget::close() to close a widget programmatically.
You can in closeEvent() of your widget B emit your own signal widgetBClose() and then connect to this signal in widget A and do what you want in this slot. A closed QWidget is hidden (i.e. not visible on screen) by definition, so, as @Kxyu said, QWidget::isVisible() can indicate whether a QWidget is closed.
UNSOLVED How To Close All Window To quit, you can use void QCoreApplication::quit() [static slot] , see http://doc.qt.io/Qt-5/qcoreapplication.html#quit.
I would try to:
void Widget::closeEvent(QCloseEvent *event)
{
[..]
event->ignore();
}
As documentation say:
"For example, you can prevent the window from closing by calling ignore() on all events."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With