0

I've been using the code from this example PyQt: How to hide QMainWindow:

class Dialog_02(QtGui.QMainWindow):
    def __init__(self, parent):
        super(Dialog_02, self).__init__(parent)
        # ensure this window gets garbage-collected when closed
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
    ...    

    def closeAndReturn(self):
        self.close()
        self.parent().show()

class Dialog_01(QtGui.QMainWindow):
    ...

    def callAnotherQMainWindow(self):
        self.hide()
        self.dialog_02 = Dialog_02(self)
        self.dialog_02.show()

It works, however when opening a second window, the window's task bar icon doesn't show. I've tried using QtGui.QDialog for the Dialog_02 as well but that gives me the same result.

How do I go about solving this?

Edit: I'm on Windows 10

Community
  • 1
  • 1
ZeZe
  • 167
  • 1
  • 14

1 Answers1

1

Just guessing (because I don't know what platform you're on, and I don't use a task-bar myself, so I cant really test it), but try getting rid of the parent:

class Dialog_02(QtGui.QMainWindow):
    def __init__(self, other_window):
        super(Dialog_02, self).__init__()
        # ensure this window gets garbage-collected when closed
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self._other_window = other_window
    ...    

    def closeAndReturn(self):
        self.close()
        self._other_window.show()
ekhumoro
  • 115,249
  • 20
  • 229
  • 336
  • I have tried your method and it does work however, when calling the closeAndReturn function to return to the Main Window it fails giving me this error: self._other_window().show() -> TypeError: 'Window' object is not callable – ZeZe Aug 03 '16 at 17:38
  • Never mind. I had writted self._other_window().show() instead of self._other_window.show() – ZeZe Aug 03 '16 at 17:46