For my QGIS Plugin, that I started with the QGIS Plugin Builder, I built a QDockWidget and populated it with some functions.

Now I want to add a QMainWindow, since I need more space for further options, but would like to keep my QDockWidget, in case that one only needs the "simple" Version of the plugin.

I now have build a simple QMainWindow with Qt and want to add it to my plugin. And this is the point where I don't know how to continue.

  • You need to explain more your issue, what is your problem? What exactly do you want to do?
    – etrimaille
    Mar 18, 2020 at 15:09

1 Answer 1


You can use the same mimic as used in your plugin class that inherits from QDockWidget.

If you look into your python code you find something that you can use the same way (provided your QtDesigner file is called my_main_window.ui):

from PyQt5 import uic
MY_FORM_CLASS, _ = uic.loadUiType(os.path.join(os.path.dirname(__file__), 'my_main_window.ui'), resource_suffix='')

class MyMainWindow(QMainWindow, MY_FORM_CLASS):

    def __init__(self, parent=None):
        super(MyMainWindow, self).__init__(parent)
        # from here you can use every designer object by self.<objectname>

    def myFunction(self):

Then you can use this with

my_win = MyMainWindow()

Sidenote: If you lack some space in your QDockWidget, have you been trying some solutions with QTabWidgets?

  • Hey Jochen, thanks for the help, this way it works! And yes already added some Tabs to my QDockWidget ;)
    – Nunkuat
    Apr 16, 2020 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.