QGraphicsScene size increases twice at once when an item is movde to its left border...
Unsolved
General and Desktop
-
I have a QGraphicsScene with a few movable items on it. When I drag an item to scene border, the size of the scene increases (it's okay, it should increase), and the scroll bars appear (that's okay too).
But even if the moving item exceeds window borders a few pixels, scene size increases about twice at once, in one big leap.
Here's a small demo (pardon my PyQt):
import sys from PyQt5 import QtWidgets, QtGui, QtCore from PyQt5.QtWidgets import QGraphicsItem, QGraphicsTextItem, QGraphicsRectItem if __name__ == "__main__": ######################################### sys._excepthook = sys.excepthook def exception_hook(exctype, value, traceback): sys._excepthook(exctype, value, traceback) sys.exit(1) sys.excepthook = exception_hook ########################################## app = QtWidgets.QApplication(sys.argv) view = QtWidgets.QGraphicsView() view.setRenderHint(QtGui.QPainter.Antialiasing) view.setMouseTracking(True) view.setDragMode(QtWidgets.QGraphicsView.RubberBandDrag) scene = QtWidgets.QGraphicsScene() rect_item = QGraphicsRectItem(-50, -50, 100, 100) rect_item.setFlags(QGraphicsItem.ItemIsSelectable | QGraphicsItem.ItemIsFocusable | QGraphicsItem.ItemIsMovable) scene.addItem(rect_item) rect_item2 = QGraphicsRectItem(-50, -50, 100, 100) rect_item2.setFlags(QGraphicsItem.ItemIsSelectable | QGraphicsItem.ItemIsFocusable | QGraphicsItem.ItemIsMovable) scene.addItem(rect_item2) rect_item2.setPos(-120, -120) view.setScene(scene) view.showMaximized() sys.exit(app.exec_())
You should drag the squares to left border, and the size will increase twice at one moment when the item reaches window border.
Cannot you tell me, how can I fix it?
-
Hi,
Can you also give which version of PyQt5, Qt and OS you are using ?