Results 1 to 4 of 4

Thread: Multiple forms inside a project

  1. #1
    Join Date
    Feb 2012
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Multiple forms inside a project

    Hi there, First of all I'm using visual studio 2010 with the QT plugin.

    In my application I wish to use different forms (duh) when user click buttons. Now I created 2 files with the designer: "RoomStd.ui" & "ResourceCompare.ui". In visual studio I right click the tree and add "existing component" and add those 2 files to the project tree (under forms).


    The moc/uic tool correctly generates ui_RoomStd.h & ui_ResourceCompare.ui. Which I use in my classes like:
    Qt Code:
    1. #include "ui_RoomStd.h"
    2. namespace MW {
    3. class RoomStdDialog : public TreeCompareDialog {
    4. Q_OBJECT
    5. public:
    6. Ui::Form ui;
    7. };
    8. }
    To copy to clipboard, switch view to plain text mode 

    (And similar for ResourceCompare).

    All fine and good: however there pops up a problem now, when compiling I get the following error:
    1>d:\my documents\visual studio 2010\Projects\GMOrganizer_GUI\GMOrganizer_GUI\Gene ratedFiles\ui_ResourceCompare.h(26): error C2011: 'Ui_Form' : 'class' type redefinition
    Looking into both header files (ui_ResourceCompare.h & ui_RoomStd.h) I see the culprit; Both headers use the "class Ui_Form" as main class for the (modal) window. Can't I use multiple designed modal windows in my application or something?

  2. #2
    Join Date
    Nov 2009
    Location
    Sacramento, CA
    Posts
    24
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Multiple forms inside a project

    You can use multiple ui files in one project. In creator, make sure to differentiate the object names of the top level widgets. That is used to compile the name of the class.

  3. #3
    Join Date
    Feb 2012
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Multiple forms inside a project

    I'm not using the creator - just the visual studio add in

  4. #4
    Join Date
    Nov 2009
    Location
    Sacramento, CA
    Posts
    24
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Multiple forms inside a project

    Sorry I meant designer. Click on the top level widget, and there is a property called ObjectName. The names of the top level widgets in different files have to be unique. The default is form.

Similar Threads

  1. Multiple Forms Handling
    By eva2002 in forum Qt Programming
    Replies: 5
    Last Post: 11th November 2010, 06:24
  2. Qt Creator Multiple Forms
    By hkaraoguz84 in forum Qt Programming
    Replies: 7
    Last Post: 8th September 2010, 14:44
  3. Help with multiple forms...!
    By hakermania in forum Qt Programming
    Replies: 8
    Last Post: 18th July 2010, 18:49
  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
  •  
Qt is a trademark of The Qt Company.