Rafael Luz
Rafael Luz

Reputation: 31

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?

Upvotes: 3

Views: 1032

Answers (1)

ekhumoro
ekhumoro

Reputation: 120808

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)

Upvotes: 3

Related Questions