PDA

View Full Version : How to disable all widgets on MainWindow except one



BIllNo123
25th August 2010, 15:27
With
mainWindow->enable(false);

i can disable all widgets on it. But i want one of the widgets NOT to be disabled. Any ideas?
Of course i can disable them one by one, but it is lot of (inefficient) code.

Lykurg
25th August 2010, 17:40
With some tricks you can find all widgets on your main window using QObject::findChildren() or QObject::children(). Then loop through them and disable them.

BIllNo123
26th August 2010, 08:29
Thanks Lykurg!
A notice: By doing
mainWindow->setEnabled(true);

it enables all widgets except those that were explicitly disabled, e.g. widget1->setDisabled(true);
In other words, it works the other way...

BIllNo123
26th August 2010, 11:41
With some tricks you can find all widgets on your main window using QObject::findChildren() or QObject::children(). Then loop through them and disable them.

Problem still. There is hierarchy between widgets so if i disable a parent then all children are disabled and they can't be enabled after that!

BIllNo123
26th August 2010, 14:13
Problem solved. I had to disable it in pieces.