[PyQt] Re: dragging a QGraphicsSvgItem

2009-03-18 Thread Matt Smith
On Wed, 2009-03-18 at 09:15 +, pyqt-requ...@riverbankcomputing.com
wrote:
 From: Wolfgang Rohdewald wolfg...@rohdewald.de
 Subject: [PyQt] dragging a QGraphicsSvgItem
 To: pyqt@riverbankcomputing.com
 Message-ID: 200903180430.09934.wolfg...@rohdewald.de
 Content-Type: text/plain;  charset=us-ascii
 
 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
I use a graphics scene and I never have to explicitly paint anything.
It seems like you could create a pixmap item when you load the svg then
you wouldn't have to render it again later.

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] Re: dragging a QGraphicsSvgItem

2009-03-18 Thread Wolfgang Rohdewald
On Mittwoch, 18. März 2009, Matt Smith wrote:
 I use a graphics scene and I never have to explicitly paint anything.
 It seems like you could create a pixmap item when you load the svg then
 you wouldn't have to render it again later.

My view scales the svg images matching to the available space, so when I
change the view size I would have to scale the pixmap too or regenerate it.

For the same reason I was wrong to use qgraphicsitem events - I have to
do it all on the view. Otherwise I could not scale the drag pixmap to
the item size in the view.


-- 
Wolfgang

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt