[PyQt] QGraphicsScene/Item/View coordinates

Frédéric frederic.mantegazza at gbiloba.org
Sun Jan 25 17:39:14 GMT 2009


On vendredi 23 janvier 2009, Frédéric wrote:

> I'm sure there is a simple way to avoid all computations I had to do
> with PyGTK, but I'm not yet familiar with this framework.

Ok, I finally have something working :o)

There is still something I would like to do, but I didn't find a 
solution...

When I create all items representing the pictures, I use the following 
code:

def paint(self, painter, options, widget):
    ...
    painter.fillRect(x, y, w, h, QtGui.QColor("green"))
    painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor"black")), 
                   BORDER_WIDTH))
    painter.drawRect(x, y, w, h)

As the scene is scaled according to its view size, to always fits, 
BORDER_WIDTH is not constant, but depends on the zoom factor (which I 
don't know, as I use fitInView()).

Is there a way to always have a border of BORDER_WIDTH pixels, whatever the 
view size is?

Thanks,

-- 
    Frédéric

    http://www.gbiloba.org



More information about the PyQt mailing list