You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

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.