[solved] Does QtDesigner support forms being copied?
-
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?
-
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.
-
That was easy. [The sound of the Staples Easy Button being pressed].
That worked perfectly. Thanks for your help.