You are not logged in.

1

Wednesday, August 25th 2010, 3:27pm

How to disable all widgets on MainWindow except one

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.

Skizmo

Beginner

  • "Skizmo" is male

Posts: 16

Occupation: Senior programmer

  • Send private message

2

Wednesday, August 25th 2010, 3:49pm

Quoted

Of course i can disable them one by one, but it is lot of (inefficient) code.

QObject has QObject::children (). With a simple loop you can disable all children and after that enable the one you don't want to disable.

3

Thursday, August 26th 2010, 8:27am

Thanks Skizmo!
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...

4

Thursday, August 26th 2010, 11:41am

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!

5

Thursday, August 26th 2010, 2:11pm

Problem solved. I had to disable it in pieces.