Hello. Know please tell me how to add windows to mdiArea. So I sketched a very simple example, but it does not work for me. I understand about why it doesn't work, but I don’t know how to fix it.

QtDesiner

enter image description here

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

Screenshot code + error

enter image description here

Error text:

 TypeError: QMdiArea.addSubWindow(QWidget, Qt.WindowFlags flags=0): argument 1 has unexpected type 'PyQt5.QtCore.pyqtWrapperType' 

    1 answer 1

    You need to create an object:

     dialog1 = Dialog() 

    You just had the type Dialog passed to self.mdiArea.addSubWindow