Different behaviour finishing an application in pyqt5 - pyqt6
Gottfried Müller
gottfried.mueller at gmx.de
Wed Mar 23 08:24:12 GMT 2022
Thanks for your answer. After reading some other sources and qt
documentations the solution was simplier. I use QApplication.exit() not
QApplication.quit()
Am 22.03.22 um 13:47 schrieb Zhao Lee:
> https://stackoverflow.com/questions/39191394/slot-of-qclipboarddatachanged-was-called-twice
> hope it helps.
>
>
>
>
>
>
> At 2022-03-22 19:02:05, "Gottfried Müller"<gottfried.mueller at gmx.de> wrote:
> >Hello,
> >
> >the follwing example shows a different behaviour in pyqt5 and pyqt6. I
> >did not found the reason. In pyqt5 after pressing the exit menu the
> >function "confirmClose" is called once, in pyqt6 twice. Closing the
> >application window does not show this effect. I wonder I am using
> >QApplication.quit but I did not find it in the Qt documentations and I
> >get no error. Substitute QApplication.quit with sys.exit has the same
> >different effect.
> >I am using manjaro pyt6.2.3, pyqt5.15.6, qt 6.2.3, qt.5.13
> >
> >import sys
> >from PyQt6.QtWidgets import QApplication, QWidget, QPushButton, QMenu,
> >QVBoxLayout
> >
> >class ApplWindow(QWidget):
> > def __init__(self, parent=None):
> > super().__init__(parent=parent)
> > btn = QPushButton("Appl menu", parent=self)
> > menu = QMenu(parent=self)
> > exitProg = menu.addAction("Exit program")
> > exitProg.triggered.connect(self.confirmClose)
> > btn.setMenu(menu)
> > layout = QVBoxLayout()
> > layout.addWidget(btn)
> > self.setLayout(layout)
> >
> > def closeEvent(self, event):
> > self.confirmClose()
> > event.ignore()
> >
> > def confirmClose(self):
> > print("close confirmed")
> > QApplication.quit()
> >
> >def main():
> > appl = QApplication(sys.argv)
> > applWindow = ApplWindow()
> > applWindow.show()
> > return appl.exec()
> >
> >
> >if __name__ == "__main__":
> > main()
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20220323/90927ee4/attachment.htm>
More information about the PyQt
mailing list