QGraphicsRectItem移出场景

时间:2019-01-09 13:58:38

标签: c++ qt qgraphicsview qgraphicsscene qgraphicsitem

我有一个图像查看器,在其中绘制了QGraphicsRectItem。 问题是QGraphicsRectItem移出了场景。 如何修复sceneRect中的项目?

我添加了rect项目。 enter image description here

我将物品向左移动,然后消失了 enter image description here

当我调整查看器的大小时,这完全变得混乱了,即QGraphicsViewer enter image description here

resizeEvent已被如下覆盖,

QTransform matrix(1, 0, 0, 0, 1, 0, 0, 0, 1);
matrix.scale(width() / sceneRect().width(), height() / sceneRect().height());
setTransform(matrix);

有什么解决方案?

0 个答案:

没有答案
相关问题