Please excuse this potentially noobish question but when trying to hide a QWidget what is the difference between calling setVisible(False), setShown(False) and hide()?
Asked
Active
Viewed 3.0k times
2 Answers
41
show()
is just a convenience function for setVisible(true)
.
Similarly hide()
is equivalent to setVisible(false)
Internally, the same code is used to render your view.
See http://doc.qt.io/archives/qt-4.7/qwidget.html#show as an example. According to it,
void QWidget::show () [slot] Shows the widget and its child widgets. This function is equivalent to setVisible(true).
You'll find lots of such functions in Qt to just make things more intuitive, especially when it comes to widgets and views.

Christophe Weis
- 2,518
- 4
- 28
- 32

Pramod
- 5,150
- 3
- 45
- 46
-
11This is only partially correct. While it is true that `hide()` is the same as `setVisible( false )`, `show()` does more than just set visibility. Depending on the default state of the window, it'll set window state (incurring a window state change notification), and _then_ it invokes `setVisible( true )`. – Dan Mar 09 '16 at 08:35
9
There is no difference. They are just different ways of achieving the same thing. (Actually setShown isn't really part of the API, it looks like it's a compatibility thing from Qt 3, so best not to use it.)

Dan Milburn
- 5,600
- 1
- 25
- 18