Setting a plain background color for a QGraphicsView widget
-
01-10-2019 - |
Question
I'm trying to display a little square of solid color.
I've created a QGraphicsView widget myGraphicsView and call:
ui->myGraphicsView->setBackgroundBrush(QBrush(Qt::red, Qt::SolidPattern));
But it stays white. What am I doing wrong?
Solution
You need to set the QGraphicsScene to the QGraphicsView before anything is drawn:
ui->myGraphicsView->setScene(myScene);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow