I have built a Qgis 3.0 Plugin which was created by QGIS Plugin Builder. The Plugin has two separate options which work perfectly (see Figure).

Figure 1: Two Options for the plugin

However, I want to attach two completely separate UIs for the two options. For the first one I already used the .ui file from the Skeleton, created by the Plugin Builder.

My Question is now: How can I create a second UI Window for the second option. It should only show two QFileDialog Items where the user can select two import directories and a run-Button.

I assume I must edit the parent attribute in the initGui method and set up another .ui instance?

For completeness a code snippet from my initGui method:

def initGui(self):
    """Create the menu entries and toolbar icons inside the QGIS GUI."""

    export_icon = ':/plugins/export_rf3d/export.png'
        text=self.tr(u'Export vector files to rockyfor3d ascii files'),

    """Import rf3d generated files and style them"""
    import_icon = ':/plugins/export_rf3d/import.png'
        text=self.tr(u'Import Files from rockyfor3D output directory'),

1 Answer 1


You can use qt designer for creating second gui. Follow the steps mentioned below

  1. Goto start menu and search Qt Designer.
  2. Start Qt Designer and make the second UI.
  3. Save this UI to the path of your plugin.
  4. Now open the file named rockyfor3d_dialog.py

Now add following lines to your rockyfor3d_dialog.py

    FORM_CLASS1, _ = uic.loadUiType(os.path.join(os.path.dirname(__file__),'name of your second UI.ui'))
    class YourDialog(QtWidgets.QDialog, FORM_CLASS1):

        def __init__(self, parent=None):
            super(YourDialog, self).__init__(parent)
            # Set up the user interface from Designer.
            # After setupUI you can access any designer object by doing
            # self.<objectname>, and you can use autoconnect slots - see
            # http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html
            # #widgets-and-dialogs-with-auto-connect

Now all that is left is to import YourDialog in rockyfor3d.py and you have second UI ready to be used.


YourDialog=The name you want to use while calling second UI in python

rockyfor3d_dialog.py=the file used to load .UI files of plugin its name may be slightly different

rockyfor3d.py= main py file of your plugin containing initGui method

  • 1
    I was able to create a 2nd UI with your help! ty! However, I would suggest to update your answer by following code snippets that have to be inserted into the rockyfor3d.py (main) file: 1. import the new UI class: from .export_rf3d_dialog import YourDialog 2. Instantiate the UI class inside the __init__ method: self.dlg2 = YourDialog()
    – Valentin
    Commented Nov 6, 2018 at 19:17

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.