Reputation: 419
I am learning right now PyQt and especially QGraphicsScene. Right now , I am trying to draw some complicated things , like for example 'human hand' , but I find QPainterPath is a little bit complicated. What can you advice ? Maybe using some openGL or some Photoshop import pictures? I am also a little bit worrying about speed, I would appreciate answers which will take in account that factor. Will put example of drawing I want to achieve. Thank you
Upvotes: 1
Views: 68
Reputation: 244003
If you want to implement complicated things then create an image as you save time.
from PySide2 import QtCore, QtGui, QtWidgets
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
scene = QtWidgets.QGraphicsScene(backgroundBrush=QtCore.Qt.gray)
w = QtWidgets.QGraphicsView(scene)
pixmap = QtGui.QPixmap("hand128.png")
pixmap_item = QtWidgets.QGraphicsPixmapItem(pixmap)
pixmap_item.setFlags(
pixmap_item.flags()
| QtWidgets.QGraphicsItem.ItemIsSelectable
| QtWidgets.QGraphicsItem.ItemIsMovable
)
scene.addItem(pixmap_item)
w.show()
sys.exit(app.exec_())
Upvotes: 2