Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cancel closing QWidget after clicking close button

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.

like image 294
Hesam Qodsi Avatar asked Sep 10 '13 09:09

Hesam Qodsi


People also ask

How do I turn off QWidget?

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.

How do I know if QWidget is closed?

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.

How to close window in Qt c++?

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.


1 Answers

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."

like image 68
vahancho Avatar answered Oct 25 '22 11:10

vahancho