Results 1 to 12 of 12

Thread: Show or hide a form

  1. #1
    Join Date
    Nov 2006
    Posts
    16
    Thanks
    3
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question Show or hide a form

    How to show or hide a dialog from another dialog???

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Show or hide a form

    Which Qt version do you use?

  3. #3
    Join Date
    Nov 2006
    Posts
    16
    Thanks
    3
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question Re: Show or hide a form

    QT 4.1

    this is the code i had written in form1.h

    #include "form2.h"

    void Form1::Show()
    {
    Form2 frm2;
    frm2.show();
    }

    This shows the form but immediately gets closed

  4. #4
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Show or hide a form

    try

    Qt Code:
    1. void Form1::Show()
    2. {
    3. Form2 *frm2 = new Form2(parentOftheForm);
    4. frm2->show();
    5. }
    To copy to clipboard, switch view to plain text mode 

  5. The following user says thank you to munna for this useful post:

    Gayathri (17th November 2006)

  6. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Show or hide a form

    Quote Originally Posted by Gayathri View Post
    QT 4.1
    Then look for "C++ GUI Programming with Qt4". The Qt3 version of this book is available for download, but I'm not sure if you can download the Qt4 edition too.

    Quote Originally Posted by Gayathri View Post
    This shows the form but immediately gets closed
    QWidget::show() is a non-blocking call and because you create frm2 on the stack it gets destroyed as soon as it goes out of scope.

    http://doc.trolltech.com/4.1/qdialog.html#return

  7. #6
    Join Date
    Nov 2006
    Posts
    16
    Thanks
    3
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Show or hide a form

    Thank you guys.
    Basically i am a C#.Net developer. I am new to this world.
    where there is no pointer concept.
    How to destroy the object created?
    *frm pointer object.

  8. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Show or hide a form

    Quote Originally Posted by Gayathri View Post
    How to destroy the object created?
    *frm pointer object.
    You can use the delete operator, but in Qt you can also set Qt::WA_DeleteOnClose widget attribute and the window will be deleted automatically as soon as it's closed.

  9. #8
    Join Date
    Jan 2006
    Posts
    52
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Show or hide a form

    The book c++ gui programming with Qt 4.1 is also available for download under the gpl licence(I think) but without the code - just the book itself. Try googling for it.

    Though in my opinion your best friend is the Qt Docs and this forum.

  10. #9
    Join Date
    Nov 2006
    Posts
    16
    Thanks
    3
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Show or hide a form

    sorry friend. how to set this attribute?

  11. #10
    Join Date
    Jan 2006
    Posts
    52
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

  12. #11
    Join Date
    Nov 2006
    Posts
    16
    Thanks
    3
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Show or hide a form

    got things when i surfed QT docs. Thanks guys

  13. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Show or hide a form

    Quote Originally Posted by Gayathri View Post
    got things when i surfed QT docs.
    You should do that in the first place Qt docs are really good, you just have to use them.

    And it's Qt not QT.

Similar Threads

  1. [Qt4.1] How to insert an image inside a Form?
    By Gonzalez in forum Qt Tools
    Replies: 5
    Last Post: 23rd September 2008, 11:20
  2. form setting
    By mickey in forum Qt Tools
    Replies: 5
    Last Post: 27th September 2006, 00:28
  3. How to create an Insert/Submit button for a form.
    By fnmblot in forum Qt Programming
    Replies: 5
    Last Post: 4th August 2006, 16:18
  4. WYSIWYG html, Window show png icon mac no!
    By patrik08 in forum Qt Programming
    Replies: 10
    Last Post: 25th May 2006, 12:01
  5. Connecting slots/signals in subclassed form
    By qball2k5 in forum Qt Programming
    Replies: 2
    Last Post: 7th March 2006, 16:01

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.