Widgets are not updated - is this a bug?

Raymond Osborn rayosborn at mac.com
Thu Jun 25 14:41:55 BST 2020


This is a bug that has been an issue since around v5.10 but which only affects Macs as far as I know. In my own code, I have had to subclass virtually every widget whose contents I change programmatically in order to add a call to repaint each time. Since I need my code to be compatible with multiplePyQt versions, I will have to leave it in even if it is fixed.

Ray

> From: Christian ARNAUD <carnaud at free.fr <mailto:carnaud at free.fr>>
> Subject: Widgets are not updated - is this a bug?
> Date: June 25, 2020 at 1:46:21 AM CDT
> To: <pyqt at riverbankcomputing.com <mailto:pyqt at riverbankcomputing.com>>
> 
> 
> Hi,
>  
> I ran in a strange behavior where widgets in the view aren’t properly refreshed on change.
> Here is the code, developed to show the problem:
>  
> import sys
> 
> from PyQt5 import QtWidgets
> from PyQt5.QtCore import Qt
> 
> 
> class MainWindow(QtWidgets.QMainWindow):
>     def __init__(self):
>         QtWidgets.QMainWindow.__init__(self)
>         self.resize(250, 100)
>         self.setWindowTitle("Demo")
>         self.centralWidget = QtWidgets.QWidget(self)
>         self.formlayout = QtWidgets.QFormLayout(self.centralWidget)
>         self.label1 = QtWidgets.QLabel('Text 1', self.centralWidget)
>         self.ledit1 = QtWidgets.QLineEdit('initial value', self.centralWidget)
>         self.bproceed = QtWidgets.QPushButton('Proceed', self.centralWidget)
>         self.bproceed.setDefault(True)
>         self.bproceed.setFocusPolicy(Qt.StrongFocus)
>         self.formlayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.label1)
>         self.formlayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.ledit1)
>         self.formlayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.bproceed)
>         self.setCentralWidget(self.centralWidget)
> 
>         self.bproceed.clicked.connect(self.on_clicked)
> 
>     def on_clicked(self):
>         self.ledit1.setText('')
> 
> 
> if __name__ == "__main__":
>     app = QtWidgets.QApplication(sys.argv)
>     win = MainWindow()
>     win.show()
>     sys.exit(app.exec())
>  
>  
> If the pushbutton is clicked with the mouse or with the space key (after getting the focus with Tab), the text in the lineedit is not refreshed. If a repaint is forced, it is.
> If the pushbutton is clicked with the enter key (after getting the focus with Tab), the text in the lineedit is correctly refreshed.
>  
> Any idea?
>  
> My env:
> OSX Catalina 10.15.5
> Python 3.6
> PyQt: 15.0
>  
> Thank you
> 
> 
> _______________________________________________
> PyQt mailing list
> PyQt at riverbankcomputing.com <mailto:PyQt at riverbankcomputing.com>
> https://www.riverbankcomputing.com/mailman/listinfo/pyqt <https://www.riverbankcomputing.com/mailman/listinfo/pyqt>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20200625/db5aa965/attachment-0001.htm>


More information about the PyQt mailing list