开发者

Setting a plain background color for a QGraphicsView widget

I'm trying to display a little 开发者_StackOverflow社区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?


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

ui->myGraphicsView->setScene(myScene);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜