Henrik Motakef wrote:
> Hi,
> 
> I want to create a QCanvasView which shows a "zoomed" version of it's Canvas. What I 
>tried looked like this:
> 
> class ZoomedCanvasView(QCanvasView):
>     def __init__(self, canvas, parent):
>         QCanvasView.__init__(self, canvas, parent)
>         matrix = self.matrix = QWMatrix()
>         matrix.scale(2,2)
> 
>     def drawContents(self, painter, cx, cy, cw, ch):
>         painter.setWorldMatrix(self.matrix)
>         QCanvasView.drawContents(self, painter, cx, cy, cw, ch)
> 
> Unfortunately this doesn't work, in several ways: First, the last four parameters 
>are not always passed, so an exception "Wrong number of arguments" is raised (This 
>usually happens only in the first call of drawContents). However, when I change it to 
>something like
> 
>    def drawContents(*args):
>        ...
>        apply(QCanvasView.drawContents, args)
> 
> another exception, "parameter 2 has wrong type", is raised - but not always. The 
>third kind of error is not raising an exception at all, but simply not redrawing the 
>CanvasItems properly after they scrolled out of the viewport an in again.
> 
> Is this a bug, or am I doing something terribly wrong?

This looks like the same problem that I've run into with QScrollView.
What is happening is that your drawContents overridden function is being called
for both QCanvasView.drawContents(self, painter, cx, cy, cw, ch) and
for QFrame.drawContents(self, painter).

The following has worked for me:

def drawContents(self, painter, clipX=None, clipY=None, \
                 clipW=None, clipH=None):
    if clipX == None:   # none is for wrong overridden function
        return QFrame.drawContents(self, painter)
    # rest of your draw code


Hope this helps,
Doug.

_______________________________________________
PyKDE mailing list    [EMAIL PROTECTED]
http://mats.gmd.de/mailman/listinfo/pykde

Reply via email to