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. Integrating Custom Widgets with Qt Designer
Forum Updated to NodeBB v4.3 + New Features

Integrating Custom Widgets with Qt Designer

Scheduled Pinned Locked Moved Unsolved General and Desktop
15 Posts 4 Posters 5.4k Views 2 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.
  • VRoninV VRonin

    Say you want to use the IconEditor in your own complex widget. instead of adding the IconEditor directly, you add a genreric Widget in designer, right click on it and promote it to tell designer that, when the program is built, that generic widget should in fact be an IconEditor.

    The obvious difference is that, inside designer, it will still show up as a gray box rather than an actual preview but in most cases it's fine

    tomyT Offline
    tomyT Offline
    tomy
    wrote on last edited by
    #6

    @VRonin
    Does it mean that we can use a pushButton as an iconEditor that way!?
    I would like if we want to use a custom widget, say, that iconEditor, we could have it like any other widget in the widget box and would drag and drop and use it.

    VRoninV 1 Reply Last reply
    0
    • tomyT tomy

      @VRonin
      Does it mean that we can use a pushButton as an iconEditor that way!?
      I would like if we want to use a custom widget, say, that iconEditor, we could have it like any other widget in the widget box and would drag and drop and use it.

      VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #7

      @tomy said in Integrating Custom Widgets with Qt Designer:

      I would like if we want to use a custom widget, say, that iconEditor, we could have it like any other widget in the widget box and would drag and drop and use it.

      That's what the first link is for: http://doc.qt.io/qt-5/designer-creating-custom-widgets.html

      While it looks cool, in my experience, most of the time you won't bother using it in production code and just go for the promote solution as it's quicker. I would go as far as to suggest you just skip to the next part of the book as Qt Designer plugins are huge niche.

      Does it mean that we can use a pushButton as an iconEditor that way!?

      Not really, the iconEditor would need to be a subclass of QPushButton for that to work. since all widgets are subclasses of QWidget, you can always use that safely

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      4
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by mrjj
        #8

        Also as a note to Designer plugin.
        Since you are using mingw compiler, a full blown plugin for Designer will not just work.

        The reason for that is a Designer plugin is a DLL and for Creator to load it, it must be made
        with SAME version of compiler as Creator was.

        On windows, it means you must be using visual studio compiler and not mingw.

        This not a restriction from Qt. its how DLLS works and goes for all frameworks.
        The only cure is to compile a new Creator with mingw OR use visual studio compiler.

        The promotion feature offer a easier way to use a custom widget in an UI file and
        is far less work.
        You can drag it back to the widget list to have as the other widgets. ( after you promote it)
        Its under "Scratch pad" label. (in bottom)

        1 Reply Last reply
        4
        • tomyT Offline
          tomyT Offline
          tomy
          wrote on last edited by
          #9

          thank you all very much for your info.
          I think those approaches (promotion or plugin) are not used often. But I will keep this guidance in mind for farther use.

          VRoninV 1 Reply Last reply
          0
          • tomyT tomy

            thank you all very much for your info.
            I think those approaches (promotion or plugin) are not used often. But I will keep this guidance in mind for farther use.

            VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by VRonin
            #10

            @tomy said in Integrating Custom Widgets with Qt Designer:

            I think those approaches (promotion or plugin) are not used often

            Promotion is used. A lot. You basically can only avoid it if you don't use ui files and build everything in code

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            tomyT 1 Reply Last reply
            0
            • VRoninV VRonin

              @tomy said in Integrating Custom Widgets with Qt Designer:

              I think those approaches (promotion or plugin) are not used often

              Promotion is used. A lot. You basically can only avoid it if you don't use ui files and build everything in code

              tomyT Offline
              tomyT Offline
              tomy
              wrote on last edited by tomy
              #11

              @VRonin
              So we could conclude that if we write Qt programs by hand code we won't be able to use the promotion approach, and we will be led to the plugin approach. This approach too is not very handy because the issues it has as mrjj spotted them. Right?

              jsulmJ VRoninV 2 Replies Last reply
              0
              • tomyT tomy

                @VRonin
                So we could conclude that if we write Qt programs by hand code we won't be able to use the promotion approach, and we will be led to the plugin approach. This approach too is not very handy because the issues it has as mrjj spotted them. Right?

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by jsulm
                #12

                @tomy No!
                If you do not use Designer (if you write UI code by hand) you do not need promotion AND plug-in approach!
                Both are needed only when using Designer.

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                1
                • mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by mrjj
                  #13

                  Hi
                  Just to be clear
                  Promotion is a feature to allow a custom widget to be used in Designer with UI files.

                  It is basically a Replace at Runtime feature allowing you to design UI files with your customs widgets
                  without having to make them full blown Designer plugins. ( which is far more work )
                  Using promotion , you can draw the GUI using Designer and it will use your custom widget when run.

                  I use promotion all the time. Its one of my favorite features allowing me both to use custom widgets AND
                  use Designer for drawing the GUI.
                  If you use Designer, its a feature you will want to use. :)

                  tomyT 1 Reply Last reply
                  3
                  • tomyT tomy

                    @VRonin
                    So we could conclude that if we write Qt programs by hand code we won't be able to use the promotion approach, and we will be led to the plugin approach. This approach too is not very handy because the issues it has as mrjj spotted them. Right?

                    VRoninV Offline
                    VRoninV Offline
                    VRonin
                    wrote on last edited by
                    #14

                    @tomy said in Integrating Custom Widgets with Qt Designer:

                    Right?

                    No. I never use Qt Designer to build my ui but just do everything by hand, for example:

                    QWidget mainWid;
                    auto mainLay = new QVBoxLayout(&mainWid);
                    mainLay->addWidget(new QLabel("Test Label",&mainWid));
                    mainLay->addWidget(new QPushButton("Useless Button",&mainWid));
                    mainWid.show();
                    

                    If, instead, you use Qt Designer, promotion will be almost impossible to avoid.

                    Designer plugins are only really relevant if you are developing widgets for other programmers to use and you want nice integration with Qt Designer, for example: http://www.devmachines.com/qtitandatagrid-overview.html

                    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                    ~Napoleon Bonaparte

                    On a crusade to banish setIndexWidget() from the holy land of Qt

                    1 Reply Last reply
                    4
                    • mrjjM mrjj

                      Hi
                      Just to be clear
                      Promotion is a feature to allow a custom widget to be used in Designer with UI files.

                      It is basically a Replace at Runtime feature allowing you to design UI files with your customs widgets
                      without having to make them full blown Designer plugins. ( which is far more work )
                      Using promotion , you can draw the GUI using Designer and it will use your custom widget when run.

                      I use promotion all the time. Its one of my favorite features allowing me both to use custom widgets AND
                      use Designer for drawing the GUI.
                      If you use Designer, its a feature you will want to use. :)

                      tomyT Offline
                      tomyT Offline
                      tomy
                      wrote on last edited by
                      #15

                      @mrjj
                      Hi,
                      Thanks for your clarification. I'm still on the side of using Qt by everything in code no Designer. It may or may not change in the future. :)

                      @VRonin
                      Thanks.

                      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