[PyQt] Modal window issue with pyqt on KDE

Michael Davies michaeld2005 at gmail.com
Wed Dec 28 10:36:56 GMT 2016


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_()

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.

Any help with this issue would be much appreciated!

Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20161228/d14fa5d8/attachment.html>


More information about the PyQt mailing list