[PyQt] Modal window issue with pyqt on KDE

Hans-Peter Jansen hpj at urpla.net
Wed Dec 28 14:02:24 GMT 2016


Hi Michael,

On Mittwoch, 28. Dezember 2016 10:36:56 Michael Davies wrote:
> Hi,
> 
> This is my first post on a mailing list - so please bear with me.
> 
> I have noticed an issue with running a modal QDialog on the KDE5 desktop.
> When I run the following code:
> 
> import sys
> from PyQt5 import QtCore
> from PyQt5 import QtWidgets
> 
> class MainWindow(QtWidgets.QMainWindow):
> 
>     def __init__(self, parent=None):
>         super(MainWindow, self).__init__(parent)
> 
>         self.openAction = QtWidgets.QAction('About', self)
>         self.openAction.triggered.connect(self.aboutDialog)
>         menuBar = self.menuBar()
>         fileMenu = menuBar.addMenu('&File')
>         fileMenu.addAction(self.openAction)
>         self.calendar = QtWidgets.QCalendarWidget(self)
>         self.setCentralWidget(self.calendar)
> 
>     def aboutDialog(self):
>         self._about = AboutDialog(self)
>         self._about.exec_()

This is related to window modality. Try self._about.show(). 
 
> class AboutDialog(QtWidgets.QDialog):
> 
>     def __init__(self, parent):
>         super(AboutDialog, self).__init__(parent)
> 
>         self.setMinimumSize(400, 350)
> 
> if __name__ == '__main__':
>     app = QtWidgets.QApplication(sys.argv)
>     app_window = MainWindow()
>     app_window.showMaximized()
>     sys.exit(app.exec_())
> 
> The issue is this - when I open the QDialog and then minimize the main
> window, the QDialog doesn't get minimized - so it is still working
> independently.  What happens exactly is that QMainWindow minimizes and
> QDialog is just left on screen.
> 
> This only happens on KDE as far as I can tell.  On openbox / xfce both
> windows are minimized.  In Windows, the QMainWindow minimize button is
> disabled when the QDialog is open.  I have ran the code on various KDE
> distros: KDE Neon Stable, Arch Linux with KDE5 and Kubuntu 16.04 - all have
> same problem.

Yes, same behavior with kwin4. Interestingly, minimizing the about dialog 
itself results in minimizing the parent, too. 

Guess, that's the price to pay for our window manager diversity..

Pete


More information about the PyQt mailing list