Using setEnabled(false) on parent widgets disables all children
Hello,
On the Qt 4.4 documentation, it states that if you set a parent widget (such as a QMainWindow) to disabled using setEnabled( false ), all children widgets are implicitly disabled.
Using this call, is there a way to keep one children widget enabled?
I know I can do something like this:
Code:
QList<QWidget*> list = parentWidget->findChildren<QWidget*>() ;
{
w->setEnabled( false ) ;
}
childWidget->setEnabled( true ) ;
But then I lose the existing enabled/disabled state of the widgets.
Thanks!
Re: Using setEnabled(false) on parent widgets disables all children
You could always put the other child widgets into group boxes & disable the group, that would keep the enable/disable status of the widget.
Vycke
Re: Using setEnabled(false) on parent widgets disables all children
Thanks Vycke.
I ended up using the method I described in my first post, because moving widgets around would have been a little messy ;)
Re: Using setEnabled(false) on parent widgets disables all children
If you want to keep the previous enabled/disabled status, you could always keep the value in a dynamic property (QObject::setProperty(const char* name, const QVariant& value) -- retrieved with QObject::property(const char* name)).
It's nice to be able to use some parts of QT/QObject in ways that you need -- such as the dynamic properties & objectName :)
Vycke