2

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?

0

1 Answer 1

1

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)

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.