[SOLVED] Difference between QWidget::hide() and QWidget::close()
-
It's desribed quite clearly in "the documentation":http://qt-project.org/doc/qt-4.8/qwidget.html#close.
::hide() only makes the widget disappear. ::close() can even destroy it in some cases.
-
bq. First it sends the widget a QCloseEvent. The widget is hidden if it accepts the close event. If it ignores the event, nothing happens. The default implementation of QWidget::closeEvent() accepts the close event.
This is QWidget::close() detail, so default behavior is, whenever the ::close() is called, it simply hides the widget, right.?
-
hide : we can reuse or display again
close : widget completely close. -
[quote author="aekam" date="1366881423"]This is QWidget::close() detail, so default behavior is, whenever the ::close() is called, it simply hides the widget, right.?[/quote]
Read the whole description. The point is: it might just hide the widget on close(), but if your settings in code are different, it might delete it completely, or even close the whole application.
If you need the widget later, use hide() or setVisible(false). If you need to destroy it, do it yourself. close() is to be used with care.
-
also, if it is the only window open in your application it quits the application... so as sierdzio said:
[quote author="sierdzio" date="1366881775"]
If you need the widget later, use hide() or setVisible(false). If you need to destroy it, do it yourself. close() is to be used with care.[/quote] -
@QtTester said in [SOLVED] Difference between QWidget::hide() and QWidget::close():
usually:
hide() = close()I don't know why you are replying to a thread last updated a decade ago! But as stated in the answers above,
hide()
does notclose()
a widget....