QLabel with scaled contents pixmap not updated after painting

Maurizio Berti <[email protected]>
Newsgroups gmane.comp.python.pyqt-pykde
Message-ID <CAPn+-XSKosNdCoFgQfeA6_f2qKUiB6_kyOYdJSZYPy6hEwr+2A@mail.gmail.com>
I noticed a strange behavior when drawing over an existing QPixmap of a
QLabel.
When scaledContents is false (the default), the image is updated correctly:

class Test(QtWidgets.QLabel):
    def __init__(self):
        super().__init__()
        self.setPixmap(QtGui.QPixmap(400, 400))

    def mousePressEvent(self, event):
        qp = QtGui.QPainter(self.pixmap())
        qp.setBrush(QtCore.Qt.white)
        qp.drawRect(100, 100, 200, 200)
        qp.end()
        self.update()

But if I use setScaledContents(True) in the init, the image is not updated
anymore, not even after calling repaint or hiding/showing the label again.
So far, the only way I found to show the changes is to set the scaled
contents to false and back again to true, right after closing the painter.

I have to specify that I'm using an old version of PyQt (5.7.1) which I
cannot update, so maybe the issue has been already solved. Also, I'm on
Linux, using xorg-x11.

Can anyone confirm this?

Maurizio

-- 
È difficile avere una convinzione precisa quando si parla delle ragioni del
cuore. - "Sostiene Pereira", Antonio Tabucchi
http://www.jidesk.net

_______________________________________________
PyQt mailing list    [email protected]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.