Hide All function?
-
I don't think that there is that functionality in Qt, but one idea is to iterate over the "QObjectList":http://doc.qt.nokia.com/latest/qobject.html#children that contains the children of that QWidget and call hide on them.
This approach will hide the children that are windows too, so maybe someone comes with a better idea.Also if you use a QMainWindow you can change the centralWidget.
LE: tell us what are you trying to achieve, why are you trying to hide everything? This will help everybody give better advices
-
I try to write a game and if player win or lose I wanna add MessageBox with "You win, yeah" or "Oh noes! you lose" and clear all the area.
Maybe without all objects it will look better than with it?:)
Or if there is no that function I'll cover the whole screen (with QPaint or something) with black or grey color and the effect will be the same, i think.
But, the best way is to hide all, i think.
-
if you want to hide all objects use
@foreach(QWidget obj, findChildren<QWidget>())
{
obj->setVisible(false);
}@even it's possible to limit the control to only one type of object for example by using QPushButton instead of QWidget.
But i don't recommend it for your application.
-
I would use a "QStackedWidget":http://doc.trolltech.com/4.7/qstackedwidget.html with one page containing the actual UI and an empty page to be shown when your message box is running.
-
[quote author="mohsen" date="1296156799"]if you want to hide all objects use
@foreach(QWidget obj, findChildren<QWidget>())
{
obj->setVisible(false);
}@even it's possible to limit the control to only one type of object for example by using QPushButton instead of QWidget.
[/quote]This works for the hiding part, but gives you problems when the widgets should be shown again. Many widgets contain subwidgets (eg. a list view in a combo box) which are found by findChildren() too and may be erroneously shown when setVisible(true) with the above code.
If you need such functionality put all the actual UI into a single container widget and hide this one or use a QStackedWidget and switch pages.