Dear Experts,
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.
http://www.qtcentre.org/threads/5660...-child-widgets
http://www.qtcentre.org/threads/5657...tially-visible
Earlier I was using QPalette to set the background color of both MainWidget and its child widgets (ChildWidget)
#include <QtGui/QWidget>
#include <QtGui/QPalette>
class MainWidget
{
---
--
private:
};
{
public:
ChildWidget(MainWidget* pParent);
---
---
private:
};
{
----
m_palette.
setColor(QPalette::Background, Qt
::white);
setAutoFillBackground(true);
setPalette(m_palette);
}
ChildWidget
::ChildWidget(MainWidget
* pParent
) : MainWidget
(pParent
), m_palette
(QPalette()){
----
m_palette.
setColor(QPalette::Background, Qt
::white);
setAutoFillBackground(true);
setPalette(m_palette);
}
#include <QtGui/QWidget>
#include <QtGui/QPalette>
class MainWidget
{
---
--
private:
QPalette m_palette;
};
class ChildWidget : public QWidget
{
public:
ChildWidget(MainWidget* pParent);
---
---
private:
QPalette m_palette;
};
MainWidget::MainWidget(QWidget* pParent) : QWidget(pParent), m_palette(QPalette())
{
----
m_palette.setColor(QPalette::Background, Qt::white);
setAutoFillBackground(true);
setPalette(m_palette);
}
ChildWidget::ChildWidget(MainWidget* pParent) : MainWidget(pParent), m_palette(QPalette())
{
----
m_palette.setColor(QPalette::Background, Qt::white);
setAutoFillBackground(true);
setPalette(m_palette);
}
To copy to clipboard, switch view to plain text mode
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?
Thanking You,
Regards
SRaju
Bookmarks