[PyQt] PyQt-based Tetr*s
jabronson at gmail.com
Wed Mar 26 20:51:29 GMT 2008
On Wed, Mar 26, 2008 at 4:48 PM, Matt Newell <newellm at blur.com> wrote:
> > Thanks Matt, that did the trick.
> > Another question has come up. When implementing this in less
> > Gui
> > frameworks<http://aipytris.googlecode.com/svn/trunk/aipytris/boardtk.py>,
> > noticed that the canvas remembered primitives that had already been
> > on it, so on each paint event I only had to paint blocks that had moved
> > since the previous paint event, which I assume is more efficient. With
> > Qt version, however, I am repainting every block on every paint event,
> > ones that have not moved. Is there some way around this? I've looked at
> > painting examples and read http://doc.trolltech.com/4.3/paintsystem.html
> > but I haven't found anything about whether QWidgets can retain state.
> > Thanks,
> > Josh
> When you call QWidget::update, it considers the entire widget to be
> By default is clears the dirty portion with the background color role.
> can disable the clearing by calling QWidget::setAttribute with
> Qt::WA_OpaquePaintEvent or Qt::WA_NoSystemBackground(i'll leave it to you
> decide which). Then you can keep track yourself what needs to be drawn.
> You can also limit the dirty region by calling update( QRect ) for each
> rect. You can call update multiple times and it will only result in a
> paint event, with all the rects joined into a QRegion.
Thanks again Matt for the lightning-fast reply. That sounds like just the
info I need. I did a quick search for "NoSystemBackground" and found
http://doc.trolltech.com/qq/qq16-background.html. Is there any other
documentation you know of that you would recommend?
A bigger question is whether you think it's worth it. Things are working
just fine the way they are now, and at most each of my BoardQt instances is
only ever going to have to paint less than 20x9 = 180 QRects per paintEvent.
Am I likely to hit scaling problems any time soon if I have a multiplayer
game with several BoardQt instances painting at once? Is it worth doing it
the efficient way just on principle?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the PyQt