开发者

QGraphicsView/QGraphicsScene rendering question

I am using QGraphicsScene/QGraphicsView pair in my application. I had subclassed them for my purpose. The code snippet that generate the pair is below:

itsScene = new QGraphicsScene;
itsView = new QGraphicsView;
itsView->setParent(itsCanvas);

itsView->setGeometry(20,20,1700,720);
itsView->setBackgroundBrush(Qt::black);
itsView->setAlignment(Qt::AlignTop);
itsView->setScene(itsScene);

After adding some widgets into QGraphicsScene my application fin开发者_StackOverflow中文版al UI snapshot is below:

QGraphicsView/QGraphicsScene rendering question

Here my question is why there is some free space above the picture? What may cause this? I am using some negative coordinates for my widgets. Is it related with that?


The negative coordinates may be the cause. QGraphicsScene calculates its bounding rect from combining the bounds of all items in it.

If you know your scene bounds, call setSceneRect to fix it down to a known rect. This way graphics items placed out of the bound will not cause the scene to expand beyond what you want.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜