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 Updated to NodeBB v4.3 + New Features

StackView index (count of items)

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 736 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 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

    KroMignonK 1 Reply Last reply
    0
    • P poucz

      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

      KroMignonK Offline
      KroMignonK Offline
      KroMignon
      wrote on 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 last edited by poucz
        #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!!

        KroMignonK 1 Reply Last reply
        0
        • P poucz

          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!!

          KroMignonK Offline
          KroMignonK Offline
          KroMignon
          wrote on last edited by KroMignon
          #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

          • Login

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