Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. StackView index (count of items)
Forum Update on Monday, May 27th 2025

StackView index (count of items)

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 731 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.
  • P Offline
    P Offline
    poucz
    wrote on 5 Jun 2020, 13:18 last edited by
    #1

    Hello,

    I have this simple code:

    Window {
        visible: true
        width: 640;height: 480
        StackView {
            id:stack
            anchors.fill: parent
    
            initialItem:Rectangle{
                anchors.fill: parent
                color:"red"
                MouseArea{
                    anchors.fill: parent
                    onClicked: {
                        console.log(stack.index)
                    }
                }
            }
        }
    }
    

    But when I clicked on the rectangle, console output is :
    qml: undefined

    how can I obtain count of items, or current index from StackView??

    Thank you

    K 1 Reply Last reply 5 Jun 2020, 15:57
    0
    • P poucz
      5 Jun 2020, 13:18

      Hello,

      I have this simple code:

      Window {
          visible: true
          width: 640;height: 480
          StackView {
              id:stack
              anchors.fill: parent
      
              initialItem:Rectangle{
                  anchors.fill: parent
                  color:"red"
                  MouseArea{
                      anchors.fill: parent
                      onClicked: {
                          console.log(stack.index)
                      }
                  }
              }
          }
      }
      

      But when I clicked on the rectangle, console output is :
      qml: undefined

      how can I obtain count of items, or current index from StackView??

      Thank you

      K Offline
      K Offline
      KroMignon
      wrote on 5 Jun 2020, 15:57 last edited by
      #2

      @poucz StackView do not have an index property, perhaps you mean depth?

      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

      1 Reply Last reply
      2
      • P Offline
        P Offline
        poucz
        wrote on 5 Jun 2020, 18:46 last edited by poucz 6 May 2020, 18:49
        #3

        Thank you! Depth is what I want.

        Can you please explain to me what is StackView.index - it is in the documentation?
        What is it for and how is it used?
        screen.png

        Thanks!!

        K 1 Reply Last reply 5 Jun 2020, 20:47
        0
        • P poucz
          5 Jun 2020, 18:46

          Thank you! Depth is what I want.

          Can you please explain to me what is StackView.index - it is in the documentation?
          What is it for and how is it used?
          screen.png

          Thanks!!

          K Offline
          K Offline
          KroMignon
          wrote on 5 Jun 2020, 20:47 last edited by KroMignon 6 May 2020, 20:50
          #4

          @poucz said in StackView index (count of items):

          What is it for and how is it used?

          StackView.index is an attached property, but it is only available in Quick.Controls 2.x, not Quick.Controls 1.x!

          initialItem:Rectangle{
              anchors.fill: parent
              color:"red"
              MouseArea{
                  anchors.fill: parent
                  onClicked: {
                      console.log(StackView.index)
                  }
              }
          }
          

          ==> see doc

          It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

          1 Reply Last reply
          1

          1/4

          5 Jun 2020, 13:18

          • Login

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