[Interest] QGraphicsProxyWidget not honoring embedded widget's palette
Murphy, Sean
Sean.Murphy at centauricorp.com
Mon Feb 21 20:57:34 CET 2022
I'm attempting to add a custom widget to a QGraphicsScene and I'm having
some trouble with the palette settings.
1. I've got a custom widget class, say "fooWidget" which is a composite widget
made up of a bunch of different child widgets (QLabels, QRadioButtons, etc.).
2. It has a setFooData(const fooData& data) function which populates all the label
text, radio buttons, etc. based off from the parameters in "data". Part of populating
everything includes changing the background colors of some of the widgets by
modifying the QPalette for those specific widgets.
This works perfectly if I instantiate the fooWidget anywhere under my MainWindow
widget hierarchy - the child widgets' text are all set correctly AND their background colors
are filled in properly.
If, however, I move that same widget onto a QGraphicsScene via
fooWidget* foo = new fooWidget();
foo->setFooData(data);
QGraphicsProxyWidget* proxy = scene->addWidget(foo)
The fooWidget is properly added to the scene, all of its child widgets' text values are
correctly updated based on whatever is in "data", BUT the widget background colors are
not updated - they are just the default values as if I hadn't attempted to change the palette.
Any way for me to get QGraphicsProxyWidget to honor the embedded widget's palette? Using
Qt 5.15.2 if that matters...
Sean
More information about the Interest
mailing list