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. [solved] Does QtDesigner support forms being copied?

[solved] Does QtDesigner support forms being copied?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.4k 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.
  • P Offline
    P Offline
    psteranka
    wrote on last edited by
    #1

    I looked for an answer to this question but didn't find one.

    I'm using Qt5.3.2 (with QtCreator 3.2.1 with QtDesigner "built in").

    I created a form on the mainwindow.ui, but after getting things working I now want to make that form into a new form and have a button on the mainwindow that will open that new form.

    I looked for a copy/paste within QtDesigner but didn't find one. Is it there?

    I tried the following work around: I copied mainwindow.ui (the XML file) to a new file Frame2.ui, and selected "Add Existing" to add the form to the project.

    I then added some code to open and display the form in the main.cpp:
    @
    Ui::Frame2 myFrame2;
    myFrame2.show();
    @

    Compiling gave me an error. show() is not a member of Frame2.

    I now realize that copying the UI (GUI) form alone did not create a Frame2.cpp, and Frame2.h file which I probably need.

    (Q) Does QtDesigner support forms being copied? If so how? If not, are there any work arounds?

    (Q) How do you open a newly created form?

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

      The "form" as you call it is just a .ui file that uic parses to generate a c++ code for inclusion in the class that is going to implement the functionality of that ui.

      So what you actually want to do is create a new class with uic generated code. Right click on a project, select "Add new" and then in the dialog select Qt section and "Qt Designer Form Class". When you finish with the wizard a new class will be created and added to your project. It will also generate a ui file with empty (if you didn't choose otherwise) widget/dialog.

      Having that you can simply select the part of the UI in the mainwindow that you want to move, then cut and paste it into the new class designer.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        psteranka
        wrote on last edited by
        #3

        That was easy. [The sound of the Staples Easy Button being pressed].

        That worked perfectly. Thanks for your help.

        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