PDA

View Full Version : Qt Creator Multiple Forms



hkaraoguz84
7th September 2010, 19:17
Hi All,

I want to add a new form to my existing Qt Project. I am using Qt Creator for designing the GUI.

In order to add a new form,

File->New File or Project -> (Files and Classes Section) -> Qt -> Qt Designer Form Class

and then I write the class name and the form is successfully added to the project with the necessary ".h" and ".cpp" files. However, creator does not create "ui_formname.h" file so when I want to use the newly generated form, a fatal error occurs because the ".cpp" file of this new form requires "ui_formname.h" which does not exist.

I am using Windows XP SP2, with Qt 4.6.0 and Qt Creator 2.0.0. I compile and run the project on MSVS 2005.

Anybody can help me to solve this problem?

Thanks.

tbscope
7th September 2010, 19:26
Qt Creator should add three (3) files
A .h file, a .cpp file and a .ui file.

It should also update the .pro file to add the new widget/dialog

If you build the code, the ui_widgetclass.h file will be automatically generated from the ui file.

If this doesn't happen, try this:
Clean your project.
Run qmake
Build your program

Does this solve the problem?

Zlatomir
7th September 2010, 19:29
Qt Creator can't generate that code for you.

You will need to manually write code to integrate those in your C++ code
Documentation (http://doc.trolltech.com/4.6/designer-using-a-ui-file.html)

hkaraoguz84
7th September 2010, 19:44
Thanks for all replies,

Actually, as tbscope said, those three files were generated.
In my previous attemps, I was directly opening the solution and trying to recreate the project.

This time, I first opened MSVS 2005 and then using Qt Visual Studio Integration menu, I recreated the solution using this new ".pro" file that is created after adding the new form. Now, I can use multiple forms so the problem is solved. :D

Thank you all for your help...

wysota
8th September 2010, 10:05
Why are you using Qt Creator then? Only for the wizards that come with it? I think the Visual Studio integration has those as well. Either switch to Creator completely or switch to VS completely.

hkaraoguz84
8th September 2010, 11:49
Why are you using Qt Creator then? Only for the wizards that come with it? I think the Visual Studio integration has those as well. Either switch to Creator completely or switch to VS completely.

I use Creator to add buttons, text boxes and other widgets to the form and also to create their slots such as "clicked" "text changed" etc... I then switch to visual studio to write the rest of the code and build the project. I haven't tried to create a form and its slots in visual studio. Is it easier? Is there a tutorial that explains all the steps (creating the form, adding widgets, buttons, creating their slots etc...) just using visual studio?

wysota
8th September 2010, 15:26
I use Creator to add buttons, text boxes and other widgets to the form and also to create their slots such as "clicked" "text changed" etc... I then switch to visual studio to write the rest of the code and build the project.
You can use Designer instead of Creator here. But Visual Studio has Designer integrated as well so you should be able to do that without leaving your IDE.

Zlatomir
8th September 2010, 15:44
If you use the Designer to get the UI file, you need to write the integration yourself? (i mean that you get only one generated .h file)
Am i right?

I didn't knew about the adding "ui form class" option... so i was wrong in my first post in this topic :o