Results 1 to 8 of 8

Thread: Qt Creator Multiple Forms

  1. #1
    Join Date
    Aug 2010
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Qt Creator Multiple Forms

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Qt Creator Multiple Forms

    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?

  3. #3
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Qt Creator Multiple Forms

    Qt Creator can't generate that code for you.

    You will need to manually write code to integrate those in your C++ code
    Documentation

  4. #4
    Join Date
    Aug 2010
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt Creator Multiple Forms

    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.

    Thank you all for your help...

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt Creator Multiple Forms

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Aug 2010
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt Creator Multiple Forms

    Quote Originally Posted by wysota View Post
    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?

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt Creator Multiple Forms

    Quote Originally Posted by hkaraoguz84 View Post
    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Qt Creator Multiple Forms

    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

Similar Threads

  1. Multiple Forms Handling
    By eva2002 in forum Qt Programming
    Replies: 5
    Last Post: 11th November 2010, 06:24
  2. Help with multiple forms...!
    By hakermania in forum Qt Programming
    Replies: 8
    Last Post: 18th July 2010, 18:49
  3. tackling multiple forms object
    By eva2002 in forum Qt Programming
    Replies: 3
    Last Post: 28th January 2010, 01:36
  4. Multiple Forms and vertical layout in forms
    By eva2002 in forum Qt Programming
    Replies: 0
    Last Post: 13th January 2010, 05:05
  5. Handling multiple forms
    By msmihai in forum Qt Programming
    Replies: 4
    Last Post: 6th December 2008, 13:41

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.