Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyQt5 - scale qgraphicsitem

Once PySide is not supported in Python 3.5, I have to move my application to PyQt5 (I know PyQt4 would be a better choice, but my company asked me to use PyQt5). I'm having a hard time trying to scale a QGraphicsPixmapItem.

In PySide, QGraphicsItem has a method scale(xFactor, yFactor). In PyQt5, it has a method setScale(factor).

My question is: how am I supposed to scale x and y independently?

like image 841
Rafael Luz Avatar asked Oct 26 '25 10:10

Rafael Luz


1 Answers

QGraphicsItem.scale(sx, sy) is obsolete even in Qt4, so you really shouldn't be using it at all. In both PyQt4 and PyQt5, use this instead:

item.setTransform(QtGui.QTransform.fromScale(xFactor, yFactor), True)
like image 56
ekhumoro Avatar answered Oct 29 '25 09:10

ekhumoro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!