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 list of used widgets
QtWS25 Last Chance

Qstackedwidget list of used widgets

Scheduled Pinned Locked Moved General and Desktop
11 Posts 4 Posters 2.8k 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.
  • A Offline
    A Offline
    amonR
    wrote on last edited by
    #1

    Hi there,
    I am wondering if it is possible to get a list of used widgets (and their names) stocked in a qstackedwidget. Exactly like when you are in QtCreator and you press Ctrl+tab (it shows the list of the last used files and put it in order). If yes, what is the best approach to realise it please?

    Thanks.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dbzhang800
      wrote on last edited by
      #2

      Yes,

      What you need is QStackedWidget::count() and
      QStackedWidget::widget()

      1 Reply Last reply
      0
      • A Offline
        A Offline
        amonR
        wrote on last edited by
        #3

        Hi (1+1=2), thanks for your reply. I know it's been a while, sorry for it.
        But I have another question.
        The documentary says that count() "holds the number of widgets contained by this stackedwidget". Sorry but I really don't get it. Does it mean that if I use count() inside a widget it will display the number of widgets my qstackedwidget has? And for widget() it will display me the name of the widget at the given index?!

        1 Reply Last reply
        0
        • A Offline
          A Offline
          amonR
          wrote on last edited by
          #4

          Please someone could clarify me on those points?!

          1 Reply Last reply
          0
          • JohanSoloJ Offline
            JohanSoloJ Offline
            JohanSolo
            wrote on last edited by JohanSolo
            #5

            Well, you quoted the doc yourself: holds the number of widgets contained by this stacked widget, this means that the QStackedWidget knows how many widgets are stacked in it, no matter if you are inside or outside of your widget.
            About QStackedWidget::widget, it gives you a pointer on the i-th widget (or zero if there is no such widget)

            `They did not know it was impossible, so they did it.'
            -- Mark Twain

            1 Reply Last reply
            0
            • A Offline
              A Offline
              amonR
              wrote on last edited by
              #6

              Hi Johan Solo xD, thanks for your answer. It's clearer now, especially for widget(): I didn't know if it was giving me the name of the widget or the widget itself.

              1 Reply Last reply
              0
              • A Offline
                A Offline
                amonR
                wrote on last edited by
                #7

                Hi guys, sorry but I have other questions:

                the doc mentions that widgets inside the qstackedwidget are part of an internal list and that each one receives an index position. But whenever the current widget changes a signal is emitted. Does it mean that the internal list updates itself and consequently the index position for each widget changes too? And why does this signal needs to be emitted?

                I really need clarifications on it please.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  andre
                  wrote on last edited by
                  #8

                  No, it does not mean that. It means that the widgets in the stack all have an index, and that only one of those indices is the current (that is: the now visible) widget. The stack is not reordered when another widget becomes the visible one.

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    amonR
                    wrote on last edited by
                    #9

                    Thanks a lot for your reply Andre.
                    Finally I don't see how count() and widget() can help me there.
                    Anyway, thanks again.

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      andre
                      wrote on last edited by
                      #10

                      count() will help you write your iteration loop. Nothing more.

                      1 Reply Last reply
                      0
                      • A Offline
                        A Offline
                        amonR
                        wrote on last edited by
                        #11

                        Thanks Andre. I am going to try and have a look at QStandardItemModel then.

                        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