Results 1 to 4 of 4

Thread: Displaying 1 widget at time

  1. #1
    Join Date
    Jul 2008
    Posts
    48
    Thanks
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Displaying 1 widget at time

    Hi everyone,

    I'm building a gui that creates a mainwindow in which there are two toolbar icons, when you click on any of them a certain dialog should appear. I have done this but it is crashing because it's not closing one widget when the other one opens. I was wondering if there is a command that will clear the CentralWidget, so that the new dialog may open without crashing. Here's my code:

    Qt Code:
    1. void MainWindow::dialog1()
    2. {
    3. if (!dialog) {
    4. dialog = new Dialog1;
    5. }
    6. this->setCentralWidget( dialog );
    7. dialog->show();
    8. }
    9.  
    10.  
    11. void MainWindow::dialog2()
    12. {
    13. if (!dialog2) {
    14. dialog2 = new Dialog2;
    15. }
    16. this->setCentralWidget( dialog2 );
    17. dialog2->show();
    18. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 162 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Displaying 1 widget at time

    try using a QStackedWidget for that.

  3. The following user says thank you to caduel for this useful post:

    afflictedd2 (14th December 2008)

  4. #3
    Join Date
    Jul 2008
    Posts
    48
    Thanks
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Displaying 1 widget at time

    I don't like the arrows in QStackedWidgets though, are these removable?

  5. #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: Displaying 1 widget at time

    They are only visible in Designer so that you can switch pages easily when designing them. When you build your application, they will go away.

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

    afflictedd2 (14th December 2008)

Similar Threads

  1. QDockWidget inside another widget in the center?
    By Antebios in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2010, 07:06
  2. displaying system time
    By aj2903 in forum Newbie
    Replies: 4
    Last Post: 2nd December 2008, 06:32
  3. Displaying Page Number on a widget
    By LiCodeX in forum Newbie
    Replies: 1
    Last Post: 23rd August 2007, 08:34
  4. Time widget
    By bruccutler in forum Newbie
    Replies: 1
    Last Post: 12th April 2007, 15:08
  5. Displaying real time images
    By Sheetal in forum Qt Programming
    Replies: 9
    Last Post: 22nd February 2007, 11:29

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.