I have a Qt widget which has a layout and there are more widgets inside it. When I disable the widget the whole widget becomes little faded and no modifications are possible anymore. I want the features that comes with disabling a widget but I do not want it's appearance to change. Please let me know how this can be done.
Few ideas that comes to my mind:
- Rather disabling widget, capture all the events on the widget and do nothing
- Update style sheet for disabled state (not sure if possible)
1. Capture events
Use
QObject::installEventFilter()andQObject::eventfilter(). Keep in mind the way Qt dispatch GUI events, in particular children get events first. So you need to install the event filter recursively on all widgets and watch forQEvent::ChildAdded.2. Using stylesheets
This is a not a good solution. Stylesheets tend to break
QStylemechanisms which may lead to side effects.3. Use a
QPixmapHide all the child widgets, render them to a
QPixmapand draw the pixmap in thepaintEvent.