CakeMaster
CakeMaster

Reputation: 1827

Setting a plain background color for a QGraphicsView widget

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?

Upvotes: 11

Views: 21168

Answers (1)

user362638
user362638

Reputation:

You need to set the QGraphicsScene to the QGraphicsView before anything is drawn:

ui->myGraphicsView->setScene(myScene);

Upvotes: 10

Related Questions