After put a rectangle in a QGraphicsScene and make it movable with the mouse, how could I resize it with the mouse?
If no one knows an answer, a example could be good too, I'm developing in Python using PYQt4, but the example can be in C++.
My simplified code:
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
scene.setSceneRect(0, 0, 512, 512)
grview.setScene(scene)
pen
= QPen(Qt.
darkMagenta)pen.setWidth(4)
item.setPen(pen)
scene.addItem(item)
grview.fitInView(scene.sceneRect(), Qt.KeepAspectRatio)
grview.show()
sys.exit(app.exec_())
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
app = QApplication(sys.argv)
grview = QGraphicsView()
scene = QGraphicsScene()
scene.setSceneRect(0, 0, 512, 512)
scene.addPixmap(QPixmap('01.png'))
grview.setScene(scene)
item = QGraphicsRectItem(0, 0, 300, 150)
pen = QPen(Qt.darkMagenta)
pen.setWidth(4)
item.setPen(pen)
item.setFlag(QGraphicsItem.ItemIsMovable)
scene.addItem(item)
grview.fitInView(scene.sceneRect(), Qt.KeepAspectRatio)
grview.show()
sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode
Bookmarks