11

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?

CakeMaster
  • 1,807
  • 4
  • 16
  • 16

1 Answers1

10

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

ui->myGraphicsView->setScene(myScene);