Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. [solved]Qt Designer: UI Form as a widget?
Forum Updated to NodeBB v4.3 + New Features

[solved]Qt Designer: UI Form as a widget?

Scheduled Pinned Locked Moved Qt Creator and other tools
11 Posts 4 Posters 14.7k Views 1 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.
  • B Offline
    B Offline
    babazaroni
    wrote on 5 Jun 2011, 13:49 last edited by
    #1

    Hello,

    Using Designer, I'd like to be able to place several instances of a widget created from a UI Form.

    What I'd like to do is create a ui form based on the QFrame, add some widgets to the frame, then save the UI form. Next, I'd like to embed a few instances of this form, in a main window form. The advantage of this, is that when I make changes to the frame ui form, the changes get propogated to the instances when the main window form is loaded again.

    I looked at widgets like QFrame, but could not find any that can contain a UI Form.

    Is there a way to do this?

    Thanks

    1 Reply Last reply
    1
    • A Offline
      A Offline
      andre
      wrote on 5 Jun 2011, 15:19 last edited by
      #2

      Sure. What you basically are doing, is creating your own widget. Just create a new QWidget-based widget using the File -> New wizard, and design the .ui the way you like it. Now, design the .ui in which you want to use those widgets. Drop in a QWidget on there, right click it, and use the Promote to... item to promote the widget to your new widget.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        babazaroni
        wrote on 5 Jun 2011, 17:05 last edited by
        #3

        Thanks. Now when I Promote To, I don't see my widget form listed, I only get to choose from the existing Q classes for the base class and a new class name. Or am i supposed to specifiy an include file? If so, I don't know how to get those from a form.

        So say my new widget is saved in a form called pad.ui. When I promote a qwidget on another form, I don't see how to specify pad.ui.

        1 Reply Last reply
        0
        • L Offline
          L Offline
          loladiro
          wrote on 5 Jun 2011, 19:32 last edited by
          #4

          You have to put QFrame (or whatever you derive your widget from) as the base class, Pad (I assume that's the name) as the class name and pad.h as the header file name.

          1 Reply Last reply
          0
          • B Offline
            B Offline
            babazaroni
            wrote on 5 Jun 2011, 21:33 last edited by
            #5

            Ok, thanks. That will have to do. I was hoping for a way to instantiate the form in Designer. Funny there isn't a widget that will load a ui form.

            1 Reply Last reply
            1
            • L Offline
              L Offline
              loladiro
              wrote on 5 Jun 2011, 21:41 last edited by
              #6

              Well, you can always open a suggestion ticket for that feature "here":http://bugreports.qt.nokia.com/browse/QTCREATORBUG

              1 Reply Last reply
              0
              • B Offline
                B Offline
                babazaroni
                wrote on 6 Jun 2011, 04:35 last edited by
                #7

                Thanks, I should make a request. Today I wrote my own plugin that instantiates a form. Not too difficult, as long as you are familiar with plugins.

                1 Reply Last reply
                1
                • A Offline
                  A Offline
                  andre
                  wrote on 6 Jun 2011, 05:30 last edited by
                  #8

                  There is already code in Qt to create a widget from a .ui file at runtime: QFormBuilder. Or do you mean that you wrote a plugin for Designer that allows you to add a .ui file as a widget on your form? That is interesting!

                  1 Reply Last reply
                  0
                  • B Offline
                    B Offline
                    babazaroni
                    wrote on 6 Jun 2011, 14:09 last edited by
                    #9

                    Yes, it's a custom widget plugin for Designer, to instantiate an arbitrary .ui form. Seems very useful, so I'm surprised the capability does not already exist.

                    1 Reply Last reply
                    0
                    • B Offline
                      B Offline
                      bence.takacs
                      wrote on 17 Oct 2013, 15:34 last edited by
                      #10

                      Is there a good solution to display the promoted widget in the design view of the main window? Now I see only empty frames and the actual widget is displayed only runtime.

                      1 Reply Last reply
                      0
                      • A Offline
                        A Offline
                        andre
                        wrote on 18 Oct 2013, 06:48 last edited by
                        #11

                        No. The only way to do that currently is to make a designer plugin instead of using widget promotion.

                        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