Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Using QUiLoader to load a composite widget
Qt 6.11 is out! See what's new in the release blog

Using QUiLoader to load a composite widget

Scheduled Pinned Locked Moved Unsolved Qt for Python
3 Posts 3 Posters 183 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    HenryInUtah
    wrote last edited by
    #1

    Hello,
    I normally create a desktop application by laying out a user interface in Qt Designer, then create a Python object (the MainWindow), and load the ui file. Something like this:

    self.ui = QtUiTools.QUiLoader().load(uiPath)
    

    The new thing is that I have to load another UI file (a QWidget) and insert it into a QFrame of my "normal" UI. This seems to work OK, but I cannot connect signals from the "new" widgets. I think it is an east fix, but I have been looking at it for hours so I have to ask for some help.

    I can't attach files to this post but I included them in the following DropBox folder:
    https://www.dropbox.com/scl/fo/ozfn00nanluloluqprypf/AMZyU6hTpLqhPQozjh1dBM0?rlkey=7i4a23eqcrkyffet9z42td5jo&st=np630341&dl=0

    There is a start.py file that loads the MainApplication.ui file. Now I have the typical application. After pressing the only button, the application loads ProjectUserInterface.ui which seems to work great. It is visible and the button seems "responsive". But when the application loads projectModule.py which is responsible for the signals and slots from the ProjectUserInterface.ui, I cannot find the button to connect its signal.

    I would really appreciate a suggestion to get around this problem. Thank you.

    JonBJ 1 Reply Last reply
    0
    • F Offline
      F Offline
      friedemannkleint
      wrote last edited by
      #2

      It seems the files cannot be downloaded with some sort of login, can you maybe paste a relevant excerpt? - Note we generally recommend using uic over QUiLoader, see https://doc.qt.io/qtforpython-6/tutorials/basictutorial/uifiles.html#tutorial-uifiles .

      1 Reply Last reply
      0
      • H HenryInUtah

        Hello,
        I normally create a desktop application by laying out a user interface in Qt Designer, then create a Python object (the MainWindow), and load the ui file. Something like this:

        self.ui = QtUiTools.QUiLoader().load(uiPath)
        

        The new thing is that I have to load another UI file (a QWidget) and insert it into a QFrame of my "normal" UI. This seems to work OK, but I cannot connect signals from the "new" widgets. I think it is an east fix, but I have been looking at it for hours so I have to ask for some help.

        I can't attach files to this post but I included them in the following DropBox folder:
        https://www.dropbox.com/scl/fo/ozfn00nanluloluqprypf/AMZyU6hTpLqhPQozjh1dBM0?rlkey=7i4a23eqcrkyffet9z42td5jo&st=np630341&dl=0

        There is a start.py file that loads the MainApplication.ui file. Now I have the typical application. After pressing the only button, the application loads ProjectUserInterface.ui which seems to work great. It is visible and the button seems "responsive". But when the application loads projectModule.py which is responsible for the signals and slots from the ProjectUserInterface.ui, I cannot find the button to connect its signal.

        I would really appreciate a suggestion to get around this problem. Thank you.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote last edited by JonB
        #3

        @HenryInUtah
        At least from C++ unless it is any different from Python/PySide: when you load a .ui file at runtime you get all its widgets but you do not get "variables" for each one, like you do when you generate code from it via uic. That means you have to "find" widgets to address them, via QWidget.findChild/findChildren() from a top-level widget. You would have to do that to read/write their values or attach signals, etc. Is that not the situation you are in?

        Which is pretty inconvenient, and one of the many reasons why most of us do not pick dynamic runtime loading of the .ui file but instead use uic to generate "variables" for each widget we can use directly, as @friedemannkleint has recommended.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved