[PyKDE] QLabel flashes on setPixmap
Ken Godee
ken at perfect-image.com
Sun Apr 18 10:19:00 BST 2004
> problem; I really only want to display/update this single graphic. How
> would I go about eliminating the flashing? I've read a bit about
> eliminating flashing in custom widgets with double buffering, but this is
> a stock Qt widget and I was surprised that updating its pixmap was so
> visually jarring.
>
> def slotUpdateImage(self):
> x, y = self.masterImage.width(), self.masterImage.height()
> if not hasattr(self, 'currentImage'):
> self.scaledImage = self.masterImage.scale(x *
> (float(self.controlframe.height()) / y),
> self.controlframe.height())
> self.currentImage = QPixmap()
> elif self.controlframe.height() != self.oldHeight:
> self.scaledImage = self.masterImage.scale(x *
> (float(self.controlframe.height()) / y),
> self.controlframe.height())
> self.oldHeight = self.controlframe.height()
>
> self.currentImage.convertFromImage(self.scaledImage)
> self.skellabel.setPixmap(self.currentImage)
>
There's probally a better way, but I've found an easy way is to try and
use something like...
def slotUpdateImage(self):
self.currentImage.hide()
(change image)
self.currentImage.show()
if you're using sizers, you might have to swap out image
with a transparent image so things don't jump around.
def slotUpdateImage(self):
self.currentImage.hide()
self.transImage.show()
(change image)
self.currentImage.show()
self.transImage.hide()
anyhow, might be something simple to try.
More information about the PyQt
mailing list