[PyQt] dragging a QGraphicsSvgItem
Wolfgang Rohdewald
wolfgang at rohdewald.de
Wed Mar 18 03:30:08 GMT 2009
While dragging it, I want to see the whole image of the item move.
What works is something like this:
(code goes into class Tile(QGraphicsSvgItem), def mousePressEvent)
...
pmapSize = self.tileset.tileSize.toSize()
if self.pixmap is None or self.pixmap.size() != pmapSize:
self.pixmap = QPixmap(pmapSize)
self.pixmap.fill(Qt.transparent)
painter = QPainter(self.pixmap)
QGraphicsSvgItem.paint(self, painter, QStyleOptionGraphicsItem())
for item in self.childItems():
QGraphicsSvgItem.paint(item, painter, QStyleOptionGraphicsItem())
drag.setPixmap(self.pixmap)
drag.setHotSpot(event.pos().toPoint())
but I do not want to render a SVG that is already rendered
Is there any way I can avoid rendering this item twice? Did I overlook
a QGraphicsSvgItem method that would return its rendered pixmap?
--
Wolfgang
More information about the PyQt
mailing list