A
A
Alexander Rublev2016-04-01 01:05:19
Python
Alexander Rublev, 2016-04-01 01:05:19

How to add window to mdiArea d PyQt5?

Hello.
Knowing please tell me how to add windows to mdiArea.
Here I sketched a very simple example, but it does not work for me. I roughly understand why it doesn't work but I don't know how to fix it.
QtDesiner
21922baa4f.jpg
Code

import sys
from PyQt5.QtWidgets import *
from PyQt5 import QtGui, QtCore
from PyQt5.uic import loadUiType

app = QApplication(sys.argv)
main_class, base_class = loadUiType('main.ui')
dialog_1_class, dialog_1_base_class = loadUiType("dialog.ui")


class MainWindow(QMainWindow, main_class):
    def __init__(self, *args):
        super(MainWindow, self).__init__(*args)
        self.setupUi(self)
        dialog1 = Dialog
        self.mdiArea.addSubWindow(dialog1)


class Dialog(QWidget, dialog_1_class):
    def __init__(self, *args):
        super(Dialog, self).__init__(*args)
        self.setupUi(self)

main = MainWindow()
main.show()
sys.exit(app.exec_())

Code screenshot + error Error
DrlVK69h4k49a2.jpg
text - TypeError: QMdiArea.addSubWindow(QWidget, Qt.WindowFlags flags=0): argument 1 has unexpected type 'PyQt5.QtCore.pyqtWrapperType'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Rublev, 2016-04-01
@Meller008

I found how to fix everything.
It is necessary to put brackets
How did I get so fucked up!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question