Problem in getting proper visibility state of the widget when using Stylesheet
I am working on an application where in which the MainWidget (Custom class of QWidget) will be the parent widget of all other widgets.
I am creating the child widgets named ChildWidget(Custom class of QWidget) dynamically and adding these child widgets into parent's widget's stack in the order which my system impose. (That means stacking order of these child widgets are controlled by my application which is an requirement of my application). Each child widget will have its own visibility state based on the widgets shown on the screen.
Based on some suggestions given by the experts in the below threads (posted by me), my application is working as expected.
Earlier I was using QPalette to set the background color of both MainWidget and its child widgets (ChildWidget)
class ChildWidget : public QWidget
MainWidget::MainWidget(QWidget* pParent) : QWidget(pParent), m_palette(QPalette())
ChildWidget::ChildWidget(MainWidget* pParent) : MainWidget(pParent), m_palette(QPalette())
Note: With our current system design the visibility state of each child widget (Refer to above link on Visibility state) has the dependency on the background-color set on it.
Now I am planning to create the MainWidget and ChildWidget using Qt Designer and set the background-color for MainWidget using the style sheet.
Open MainWidget.ui -> Right click on the MainWidget -> Change Stylesheet -> select the back ground color -> apply & say OK -> save MainWidget.ui
Here are my questions:
a. Is there a way to apply the common style sheet at the parent widget level (for ex MainWidget) so that it applies all its child widgets of type (ChildWidget) without altering their visibility state?
b. How do I know that style sheet data is propagated from parent widget to child widgets?
You can set the style sheet application wide. After that, it's how you write your style sheet that determines where it will be applied (it also applies to setting the style sheet to the parent widget)
Thank you for the response. That helps me!