'How to re-enable the background of QGraphicsView's child widgets?

When adding QWidgets such as QGroupBox and QFrame to a layout set on QGraphicsView, those widgets have no background. Various things that seem like they should re-enable it, do not work. (E.g., setAutoFillBackground(true);.)

Is there some way to get the widgets to draw their background again?

QFrame*         mycw    = new QFrame();
QHBoxLayout*    loMain  = new QHBoxLayout();
    loMain->addWidget( mycw );
    pView = new QGraphicsView();
    pView->setLayout( loMain );
    pView->showFullscreen();

Edit: This may have something to do with opengl or something. I have tried to work around it, by making the two widgets peers - and using the resizeEvent of the parent to arrange them with no layout at all. And it still happens! If it's drawn in-front of the QGraphicsView, it ends up with no background.

I will have to dig deeper. :(



Solution 1:[1]

If you want to apply a background color on a widget you can use maybe:

widget->setStyleSheet("background-color: yellow");

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mmerle