Results 1 to 4 of 4

Thread: How to show a window widget...

  1. #1
    Join Date
    Jun 2006
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to show a window widget...

    ... from a QMainWindow ? (but not in main.cpp)

    in CLinkGUI.cpp :
    Qt Code:
    1. void CLinkGUI::tests()
    2. {
    3. ui_sofImpl test;
    4. test.show();
    5. }
    To copy to clipboard, switch view to plain text mode 

    When I do this :
    in main.cpp :
    Qt Code:
    1. int main(int argc, char **argv)
    2. {
    3. QApplication app(argc, argv);
    4. ui_murefImpl window;
    5. window.show();
    6.  
    7. ui_sofImpl test;
    8. test.show();
    9.  
    10. return app.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 
    it works but that is not what I want...

    my not modified main.cpp :
    Qt Code:
    1. int main(int argc, char **argv)
    2. {
    3. QApplication app(argc, argv);
    4. ui_murefImpl window;
    5. window.show();
    6.  
    7. return app.exec();
    8. }
    To copy to clipboard, switch view to plain text mode 


    The first code (in CLinkGUI.cpp) shows me my widget but close it imediately...

    Thanks !

    Please delete this topic -> I found the solution : Read the FAQ !
    Last edited by agent007se; 20th July 2006 at 06:48.

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

    Default Re: How to show a window widget...

    The first code (in CLinkGUI.cpp) shows me my widget but close it imediately...
    Because the widget is created in the function tests() and destroyed once out of the function.

    It should rather be

    Qt Code:
    1. void CLinkGUI::tests()
    2. {
    3. ui_sofImpl *test = new ui_sofImpl;
    4. test->show();
    5. }
    To copy to clipboard, switch view to plain text mode 

    Make sure you set the widget attribute Qt::WA_DeleteOnClose so that the widget is deleted automatically when it is closed.

  3. #3
    Join Date
    Jun 2006
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to show a window widget...

    Quote Originally Posted by munna
    Because the widget is created in the function tests() and destroyed once out of the function.

    It should rather be

    Qt Code:
    1. void CLinkGUI::tests()
    2. {
    3. ui_sofImpl *test = new ui_sofImpl;
    4. test->show();
    5. }
    To copy to clipboard, switch view to plain text mode 

    Make sure you set the widget attribute Qt::WA_DeleteOnClose so that the widget is deleted automatically when it is closed.
    I just added static before declaration of the variable :

    Qt Code:
    1. static ui_sofImpl test;
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: How to show a window widget...

    I just added static before declaration of the variable
    Take a look at the FAQ please...

Similar Threads

  1. accessing my main application window widget
    By jayw710 in forum Newbie
    Replies: 8
    Last Post: 15th November 2007, 19:33
  2. WYSIWYG html, Window show png icon mac no!
    By patrik08 in forum Qt Programming
    Replies: 10
    Last Post: 25th May 2006, 12:01
  3. Corner widget in QTabWidget doesn't show up
    By ePharaoh in forum Qt Programming
    Replies: 2
    Last Post: 6th April 2006, 17:02
  4. [Qt 4.1.0] Split a widget on demand
    By Townk in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2006, 14:16
  5. Replies: 12
    Last Post: 15th February 2006, 10:46

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.