Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QStackedWidget hiding pages

QStackedWidget hiding pages

Scheduled Pinned Locked Moved General and Desktop
qstackedwidgetpagewidgets
2 Posts 2 Posters 2.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    stvokr
    wrote on last edited by
    #1

    Hi all,

    I want to hide pages of a stacked widget, because I have a Dialog with multiple contents. Each page has a different size due to the different widgets on the page, e. g. "Single" is very small (200x300 pixels) and "Multi" is very big (1000x600 pixels) (see code below). So the Dialog should be resized to fit its current visible content. But this does not work if the other pages are still visible, so hiding them would be a good idea.

    In Header File:

    enum Type { Single, Multi, Other };
    

    In Source File:

    void FormDialog::setPage( Type type )
    {
        ui->page_single->setVisible( type == Single );
        ui->page_multi->setVisible( type == Multi );
        ui->page_other->setVisible( type == Other );
    }
    

    But this does not work.
    It works if I insert groupboxes as children of the pages and the other widgets in the groupboxes and hide the groupboxes.
    What's the problem here?

    regards,
    Oliver

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Rondog
      wrote on last edited by
      #2

      My first thought is that QGroupBox probably provides a sizehint() that is zero if the widget is not visible where your other widget probably does not do this.

      The QStackedWidget would provide a sizehint() based on all of the children. When you hide the children you make the end result no smaller than the largest child.

      Another idea to implement this is to have a common set of options always visible and show/hide the additional parts that are unique to the 'multi' and 'other' views. This will autosize.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved