Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Can I “instantiate” (parametrize) prepared ui form by placing it in another form in Qt designer?
Qt 6.11 is out! See what's new in the release blog

Can I “instantiate” (parametrize) prepared ui form by placing it in another form in Qt designer?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 2.3k Views 3 Watching
  • 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.
  • M Offline
    M Offline
    MXXIV
    wrote on last edited by
    #1

    I created a simple form object representing some arbitrary name and value pair:

    image description

    It's intentionally very simple - any design is to be applied through the CSS styles. Apart from the UI, the form consists of C++ class that handles the data loading and custom property defined in Designer too - the name of the data source (eg. hostname).

    image description

    So I have two values I need to parametrize:

    • the Name - the QLabel text
    • the datapoint - some hostname. This will be later loaded by the C++ class and tell it what data should be loaded

    I was Imagine I would be able to create "instances" of my form manually in designer and assign parameters to them. Like in this fictional image:

    image description

    Don't forget datapoint is the custom dynamic attribute. I am sure the described design can be easily carried out programatically, but I feel like the designer solution will be prettier - provided there's a legit way to do it.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Do you mean you need something like a widget plugin for designer like described here ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Chris KawaC Offline
        Chris KawaC Offline
        Chris Kawa
        Lifetime Qt Champion
        wrote on last edited by
        #3

        I don't think this is doable currently without modifying Qt sources.
        There's very little extensibility of the designer when it comes to custom data. All you can do is provide a fixed set of meta object properties, but even those are quite limited. For example there seems to be no way to make a vector of objects assignable in the designer or even assign actions or toolbars in your custom designer plugins.
        You need to remember that all the designer does is generate an xml description of the ui. The tool that does the actual code gen is uic, and you would need to extend it to understand any extra syntax in the xml generated from the designer, yet there is no way to do so beyond modifying the uic itself.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          MXXIV
          wrote on last edited by
          #4

          I think you don't understand yet. All I need to put form from my template UI file to another form, with properties. Like copy and paste. But it is promoted to a class and it must stay that way.

          mrjjM 1 Reply Last reply
          0
          • M MXXIV

            I think you don't understand yet. All I need to put form from my template UI file to another form, with properties. Like copy and paste. But it is promoted to a class and it must stay that way.

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            hi
            Do you mean like this poster?
            https://forum.qt.io/topic/61237/how-to-have-multiple-widgets-initialized-from-a-single-form-file-no-aggregation-inheritance

            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