I have 2 classes :

  • first class : a "processing class" running some calculation;
  • second class : a "ui" class that displays a progress bar and a label.

The goal is, as the calculations of the first class progress, to display the second class interface and update its progress bar.

Here is what I wrote for the calculation class :

from .interface2_dialog import Interface2Dialog

class MyCalculation:
    def __init__(self, parent=None):
        self.interface2Dialog = Interface2Dialog()

    def runCalculation(self):

        # Initialize progress bar
        # Update progress bar

And here is what I wrote for the ui class :

FORM_CLASS, _ = uic.loadUiType(os.path.join(
os.path.dirname(__file__), 'interface2_dialog_base.ui'))

class Interface2Dialog(QtWidgets.QDialog, FORM_CLASS):
    def __init__(self, projectDataInput, parent=None):
        super(Interface2Dialog, self).__init__(parent)

        self.setWindowFlags(self.windowFlags() | QtCore.Qt.WindowStaysOnTopHint)

    def setProgressBar(self, myValue):
        # Set progress bar percent value

    def setLabel(self, myValue):
        # Set label name

The method "runCalculation" is the one being called.

"progressBarUi" is the ui progress bar object, as created with QtDesigner.

"labelUi" is the ui label object as created with QtDesigner as well.

Since it does not work, I suppose I did something wrong. The calculation is being run to the end, the ui is displayed on the foregrount, but it is empty.

Why is it empty ? My window should at least be initialized with QtDesigner.

  • 1
    Even if it's for a QGIS plugin, this is not really a GIS related question, you'll have more chance to have a great answer on StackOverflow for a pure Qt5 question. May 22 at 8:47


Your Answer

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

Browse other questions tagged or ask your own question.