[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] can't create a QPainter in QTreeWidget's paintEvent
From:       Devon <devon.rueckner () temboo ! com>
Date:       2007-08-23 15:51:55
Message-ID: 19245fa20708230851m3082b26o180f80d31c5757f3 () mail ! gmail ! com
[Download RAW message or body]

On 8/23/07, David Boddie <david@boddie.org.uk> wrote:
> On Thu Aug 23 16:04:19 BST 2007, Devon wrote:
>
> > > If you pass a device (self in this case) when you create a QPainter, don't
> > > call its begin() or end() methods. I think its the end() call that
> > > actually triggers this message in this case.
> >
> > I'm not explicitly calling begin() - I believe that's happening in
> > QPainter(self).  painter.end() is not the root cause.
>
> OK. I just noticed the use of an explicit end() without an explicit begin()
> and jumped to conclusions about the cause of the problem. Sorry about that.
>
> Anyway, it looks like we're trying to paint onto the wrong device - the
> QAbstractScrollArea documentation for its paintEvent() method says this:
>
>   This event handler can be reimplemented in a subclass to receive paint
>   events (passed in event), for the viewport() widget.
>
>   Note: If you open a painter, make sure to open it on the viewport().
>
> So you write your paintEvent() to do this instead:
>
>     def paintEvent(self, e):
>         QTreeWidget.paintEvent(self, e)
>         painter = QPainter(self.viewport())
>
> David


Perfect.  Thanks for your help!

~ Devon
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic