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. Hide pages in Stacked Widget

Hide pages in Stacked Widget

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 4 Posters 2.0k Views 2 Watching
  • 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.
  • michalt38M Offline
    michalt38M Offline
    michalt38
    wrote on last edited by
    #1

    Hello, is there a way to hide some pages dynamically in a Stacked Widget?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      The page is just a widget so it can be hidden as such BUT
      it still exits in its list and as far as i know, it wont skip over them
      when u set setCurrentIndex(int index)
      So if u need various pages at different times, i think you have to use
      void QStackedWidget::removeWidget(QWidget *widget)
      to truly hide it.

      Is this some kind of Wizard ?

      1 Reply Last reply
      1
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3

        say you have 3 pages (a,b,c), you hide the second (b) what should happen if you call setCurrentIndex(1)?

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        2
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          You have full control over which page is shown when you call setCurrentIndex(). So if you have, for example, some "Next" button which activates next page, you can implement "hiding" like this:

          void on_next_clicked()
          {
            int i = stack->currentIndex();
            i++;
            if (i == 5) {
              // Oh! I want to skip page with index 5
              i++;
            }
            stack->setCurrentIndex(i);
          }
          

          (Z(:^

          1 Reply Last reply
          4

          • Login

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