What's the difference in Qt between setVisible, setShown and show/hide

岁酱吖の 提交于 2019-12-21 06:55:47

问题


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()?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/12177801/whats-the-difference-in-qt-between-setvisible-setshown-and-show-hide

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!