[PyKDE] Invalidation of windows

David Boddie david at boddie.org.uk
Wed Mar 23 15:28:57 GMT 2005

On Sun, 20 Mar 2005 21:37:44, Jeremy Sanders wrote:

> I keep hitting a strange problem with Qt. I don't think the problem's in
> my code! Any idea how I can avoid this?
> I have a document class which has a "dirty" flag. My output window (a
> QScrollView), checks the flag at intervals (using a QTimer). If the flag
> is set self.UpdateContents() is called.

Couldn't you use signals and slots for this? Make the document class a
QObject subclass and connect a custom signal from there to your
UpdateContents method.

> In drawContents(), it checks the flag. If it is set it puts the output
> into a buffer pixmap, and uses painter.drawPixmap to put that to the
> QScrollView (over the entire thing if the dirty flag is set). The dirty
> flag is then reset.

OK. So far, I follow what you mean.

> I'm having problems where only part of the output window is getting
> overwritten using this procedure. It looks like Qt is doing some sort of
> clipping in drawContents(). This happens particularly with a popup menu
> which changes the program's output. When the popup closes, only the window
> beneath the popup is repainted. I can get round it much of the time by
> putting a app.eventLoop().processEvents(allevents, 100000) after the popup
> exec_loop().

So do you want to repaint the whole canvas when the popup closes?
I assume that the sequence of events is:

 1. Open the popup.
 2. The user does something to change the entire picture/diagram/whatever.
 3. The popup closes.
 4. You try to paint over the whole scrollview, but only the area revealed
    by the popup is updated.

This might be related to your use of timers to update the scrollview.

> Has anyone hit this problem before? Am I doing something stupid??
> Now I need to work out how to get the random maybeTip tooltip exceptions I
> get occassionally...

You'll need to post some code that shows what you're trying to do. If it's a
big example then post a URL instead.


More information about the PyQt mailing list