Results 1 to 15 of 15

Thread: All widgets are visible in QStackedWidget

  1. #1
    Join Date
    Apr 2006
    Location
    Saint-Petersburg, Russia
    Posts
    63
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default All widgets are visible in QStackedWidget

    Hello, All !

    I have to process 4 different dialogs in QStackedWidget.
    I do this
    Qt Code:
    1. wsForm = new WsPropertiesForm (0, false, 0);
    2. QSize cwSize (wsForm->maximumSize ());
    3. rForm = new RasterPropertiesForm (false, 0);
    4. dForm = new DocumentPropertiesForm (0, false, 0);
    5. lForm = new LayerPropertiesForm (0, false, 0);
    6. ...
    7. int wsIndex = this->ResultsStackedW->addWidget (wsForm);
    8. int rIndex = this->ResultsStackedW->addWidget (rForm);
    9. int dIndex = this->ResultsStackedW->addWidget (dForm);
    10. int lIndex = this->ResultsStackedW->addWidget (lForm);
    11. this->ResultsStackedW->setCurrentIndex (0);
    12. ...
    To copy to clipboard, switch view to plain text mode 
    In form constructor. When this form is shown, I see all these widgets simultaneously. Where is error ? I have to see these forms code ?
    Best regards,
    Yuriy Rusinov.

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

    Default Re: All widgets are visible in QStackedWidget

    Can we see a screenshot?

  3. #3
    Join Date
    Apr 2006
    Location
    Saint-Petersburg, Russia
    Posts
    63
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: All widgets are visible in QStackedWidget

    Oh, I'm sorry. Here it is
    Attached Images Attached Images
    Best regards,
    Yuriy Rusinov.

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

    Default Re: All widgets are visible in QStackedWidget

    What happens if you substitute your form objects with for example QTextEdit?

  5. #5
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: All widgets are visible in QStackedWidget

    Are you using QDialog as a base class for your forms?
    This might be the problem then:
    Note that QDialog (an any other widget that has type Qt:ialog) uses the parent widget slightly differently from other classes in Qt. A dialog is always a top-level widget, but if it has a parent, its default location is centered on top of the parent's top-level widget (if it is not top-level itself). It will also share the parent's taskbar entry.

  6. #6
    Join Date
    Apr 2006
    Location
    Saint-Petersburg, Russia
    Posts
    63
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: All widgets are visible in QStackedWidget

    All works fine.
    Best regards,
    Yuriy Rusinov.

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

    Default Re: All widgets are visible in QStackedWidget

    Then the problem is probably in your forms implementations. Do you by any chance call show() on them somewhere?

  8. #8
    Join Date
    Apr 2006
    Location
    Saint-Petersburg, Russia
    Posts
    63
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: All widgets are visible in QStackedWidget

    Quote Originally Posted by high_flyer View Post
    Are you using QDialog as a base class for your forms?
    This might be the problem then:
    You're right. Base class for these forms is QDialog, because they have to be used in two different modes, as modal form and widget on another form.
    Last edited by YuriyRusinov; 21st March 2007 at 12:25. Reason: spelling error
    Best regards,
    Yuriy Rusinov.

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

    Default Re: All widgets are visible in QStackedWidget

    Quote Originally Posted by YuriyRusinov View Post
    You're right. Base class for these forms is QDialog, because thea\y have to be used in two different modes, as modal form and widget on another form.
    Implement them as widgets then and wrap into QDialog only when you need it.

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

    YuriyRusinov (21st March 2007)

  11. #10
    Join Date
    Apr 2006
    Location
    Saint-Petersburg, Russia
    Posts
    63
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: All widgets are visible in QStackedWidget

    OK, What functions have to be reimplemented in order to transform form to dialog ?
    Best regards,
    Yuriy Rusinov.

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

    Default Re: All widgets are visible in QStackedWidget

    All you need is this:
    Qt Code:
    1. QDialog dlg;
    2. QVBoxLayout *l = new QVBoxLayout(&dlg);
    3. MyWidget *w = new MyWidget;
    4. l->addWidget(w);
    5. dlg.exec();
    To copy to clipboard, switch view to plain text mode 

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

    YuriyRusinov (21st March 2007)

  14. #12
    Join Date
    Apr 2006
    Location
    Saint-Petersburg, Russia
    Posts
    63
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: All widgets are visible in QStackedWidget

    Thanks a lot, problem was solved by similar method.
    Qt Code:
    1. QWidget * cW = new QWidget ;
    2. QVBoxLayout *lW = new QVBoxLayout (cW);
    3. lW->addWidget (wForm);
    To copy to clipboard, switch view to plain text mode 
    Best regards,
    Yuriy Rusinov.

  15. #13
    Join Date
    Apr 2006
    Location
    Saint-Petersburg, Russia
    Posts
    63
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: All widgets are visible in QStackedWidget

    I solved this problem. But I have one question. Because QDialog class inherits QWidget, can I set appropriate flags/properties for direct show in QStackedWidget (or QStackedLayout) ?
    Best regards,
    Yuriy Rusinov.

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

    Default Re: All widgets are visible in QStackedWidget

    QStackedLayout is not a widget so obviously you can't set any flags there. What do you mean by "direct show"?

  17. #15
    Join Date
    Apr 2006
    Location
    Saint-Petersburg, Russia
    Posts
    63
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: All widgets are visible in QStackedWidget

    I'm sorry. My question was can I set some flags and/or properties on my forms and make
    Qt Code:
    1. stackedLayout->addWidget (form1);
    2. ...
    To copy to clipboard, switch view to plain text mode 
    to receive the same results ?
    Best regards,
    Yuriy Rusinov.

Similar Threads

  1. Performance in hiding/showing widgets
    By Paalrammer in forum Newbie
    Replies: 12
    Last Post: 14th February 2007, 18:57
  2. Replies: 11
    Last Post: 7th July 2006, 13:09
  3. How to movable dock widgets?
    By becond in forum Qt Tools
    Replies: 3
    Last Post: 21st February 2006, 19:57
  4. Creating Widgets
    By hylke in forum Qt Programming
    Replies: 2
    Last Post: 5th February 2006, 08:37
  5. How do I find out which widgets/canvas items are visible?
    By Tommytrojan in forum Qt Programming
    Replies: 11
    Last Post: 6th January 2006, 13:22

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.