TransWikia.com

Implementation of a multi tab plugin

Geographic Information Systems Asked by user9591000 on February 17, 2021

I have successfully built my multi tab gui in Qt Creator but I don’t know how do I implement it in the code. I already have my plugin files. I generated them using Plugin Builder. So how do I implement it from there?

One Answer

You will need to load your qt ui file to a Python class. If you use the Plugin Builder with template "Tool button with dialog" it will show you the entire code. From the Sherman builder:

import os

from qgis.PyQt import uic
from qgis.PyQt import QtWidgets

# This loads your .ui file so that PyQt can populate your plugin with the elements from Qt Designer
FORM_CLASS, _ = uic.loadUiType(os.path.join(
    os.path.dirname(__file__), 'photo_linker_dialog_base.ui'))


class PhotoLinkerDialog(QtWidgets.QDialog, FORM_CLASS):
    def __init__(self, parent=None):
        """Constructor."""
        super(PhotoLinkerDialog, self).__init__(parent)
        # Set up the user interface from Designer through FORM_CLASS.
        # After self.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
        self.setupUi(self)

Correct answer by Jakob on February 17, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP