Results 1 to 6 of 6

Thread: More than one form

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2008
    Posts
    3
    Thanks
    3

    Default More than one form

    Hi,

    Just using designer so far and am very new to this. I have a main window form, with a menu bar. Now I have designed other forms for when one of the options on the main menu bar is triggered (i.e. an "About this application" form, a "Contact" form etc).

    My problem is that I don't know how to show these forms from the main. I mean I double click on the action editor action (using VS2003 integrated with QT 4) and am brought to the app.cpp file with the action created

    void protoGUIOne:n_actionProject_triggered()
    {

    }
    Now I've tried lots of things in there to get it to show, but nothing seems to work. I've been looking around but can't find anything.

    I relaise this is probably a ridicuosly easy problem but I'm a true newbie and am confused!

    Any help appreciated.

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 370 Times in 336 Posts

    Default Re: More than one form

    when you created main form with needed actions, you should connect these action to slots and then in slots you should create (or show) needed widget.
    e.g.
    Qt Code:
    1. MyMainWindow::MyMainWindow(QWidget *parent)
    2. : QMainWindow(parent), m_myHelp(0)
    3. {
    4. ....
    5. }
    6. ....
    7. void MyMainWindow::actionHelp()
    8. {
    9. if (!m_myHelp)
    10. m_myHelp = new MyHelpWidget(this);
    11. m_myHelp->show();
    12. }
    13. ...
    To copy to clipboard, switch view to plain text mode 
    this is only one variant.

  3. The following 2 users say thank you to spirit for this useful post:

    fnmblot (30th September 2008), newToQT (1st October 2008)

  4. #3
    Join Date
    Sep 2008
    Posts
    3
    Thanks
    3

    Default Re: More than one form

    Thanks for replying. I'm still having trouble though.

    I'm going through the tutorials (and am feeling really scared!) and see nothing that addresses this in a simple way. I mean I'm just starting yet but want to get this little problem fixed, I knwo it's simple!

    I tried doing what you said but still got errors.

    In an effort to understand I've just done up a simple program, two forms. One with a pushbutton that opens the other. Still no luck, I thought if I could get that going then any others would be easy.

    Is there another way of doing it?
    Attached Files Attached Files

  5. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 370 Times in 336 Posts

    Default Re: More than one form

    so, I modified your example in which you can see that there is nothing difficult of using signal and slots.
    Attached Files Attached Files

  6. The following user says thank you to spirit for this useful post:

    newToQT (2nd October 2008)

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

  8. The following user says thank you to wysota for this useful post:

    newToQT (2nd October 2008)

  9. #6
    Join Date
    Sep 2008
    Posts
    3
    Thanks
    3

    Default Re: More than one form

    Thanks so much guys. You both really helped me out.

Similar Threads

  1. Pass variable from a form to another form
    By dark1988 in forum Qt Programming
    Replies: 5
    Last Post: 8th February 2011, 18:19
  2. Help me to load one form over another form PushButton
    By wagmare in forum Qt Programming
    Replies: 7
    Last Post: 26th November 2008, 16:11
  3. visible main form?
    By triperzonak in forum Newbie
    Replies: 1
    Last Post: 12th June 2008, 09:00
  4. Hiding a form and opening another form
    By anafor2004 in forum Newbie
    Replies: 1
    Last Post: 20th February 2008, 15:04
  5. Calling a new form from current form
    By webgenius in forum Qt Programming
    Replies: 7
    Last Post: 8th April 2007, 19:50

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.