Python Forum
[PyQt] App crashes when reopening a subwindow
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt] App crashes when reopening a subwindow
#11
The maximum size of the subwindow is the size of the mdiArea.
Reply
#12
(Aug-03-2021, 07:30 PM)Axel_Erfurt Wrote: The maximum size of the subwindow is the size of the mdiArea.

I see... That's an issue then. Is there a way to make the size of the subwindow be independent from the mdiArea though?
Reply
#13
I think the only way for a fixed size is not to use it as mdiArea subwindow and make it ontop.

 
    def OpenUserForm(self):
        self.swu = SubWindowUsers()
        self.swu.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
        self.swu.setFixedSize(QtCore.QSize(400, 300))
        self.swu.move(QtCore.QPoint(self.geometry().x() + 2, self.geometry().y() + 30))
        #self.mdiArea.addSubWindow(self.swu)
        self.swu.setWindowTitle("Users")
        self.swu.show()
        self.statusbar.showMessage("Users Window opened", 0)
Reply
#14
(Aug-03-2021, 08:13 PM)Axel_Erfurt Wrote: I think the only way for a fixed size is not to use it as mdiArea subwindow and make it ontop.

Hi, Axel. I figured out a way of doing it. I started from scratch and kept the code to a bare minimum. I will add the other features later. Now it works exactly the way I want it:

from PyQt5.QtWidgets import QApplication, QMainWindow, QMdiArea, QAction, QMdiSubWindow, QTextEdit
import sys


class MDIWindow(QMainWindow):
    count = 0

    def __init__(self):
        super().__init__()

        self.mdi = QMdiArea()
        self.setCentralWidget(self.mdi)

        bar = self.menuBar()
        file = bar.addMenu("File")
        file.addAction("New")
        file.addAction("Cascade")
        file.addAction("Tile")

        self.setWindowTitle("MDI Application")

        file.triggered[QAction].connect(self.WindowTrig)

    def WindowTrig(self, p):

        if p.text() == "New":
            MDIWindow.count = MDIWindow.count + 1
            sub = QMdiSubWindow()
            sub.setWidget(QMainWindow())
            sub.setWindowTitle("Sub window " + str(MDIWindow.count))
            self.mdi.addSubWindow(sub)
            sub.setFixedSize(400, 300)
            sub.show()

        if p.text() == "Cascade":
            self.mdi.cascadeSubWindows()

        if p.text() == "Tile":
            self.mdi.tileSubWindows()


app = QApplication(sys.argv)
mdiwindow = MDIWindow()
mdiwindow.show()
app.exec_()
Thanks again for all your help!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  GUI crashes flash77 3 861 Jul-26-2023, 05:09 PM
Last Post: flash77
  [Tkinter] Clicking on the button crashes the TK window ODOshmockenberg 1 2,196 Mar-10-2022, 05:18 PM
Last Post: deanhystad
  [PyQt] Subwindow catlessness 5 2,782 Oct-23-2021, 06:28 PM
Last Post: catlessness
  [PyQt] Can't neither setWindowFlags nor setFixedSize of a subwindow. JayCee 10 4,024 Aug-06-2021, 08:06 PM
Last Post: JayCee
  Running external Python file as a subwindow JayCee 13 3,817 Aug-05-2021, 05:47 AM
Last Post: ndc85430
  [PyGUI] My GUI crashes after command MLGpotato 1 1,855 Feb-21-2021, 03:17 PM
Last Post: deanhystad
  [PyQt] PyQT5 Thread crashes after a while Suresh 0 1,950 Jul-21-2020, 07:53 AM
Last Post: Suresh
  PyQt5 : Interpreter Crashes While Initializing Message Box iMuny 7 5,602 Aug-29-2019, 01:38 PM
Last Post: iMuny

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020