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. Customizing PageIndicator
Forum Update on Monday, May 27th 2025

Customizing PageIndicator

Scheduled Pinned Locked Moved Solved QML and Qt Quick
pageindicatorcontrols 2
3 Posts 2 Posters 2.6k 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.
  • M Offline
    M Offline
    Mark81
    wrote on 7 Jul 2016, 06:15 last edited by Mark81 7 Jul 2016, 06:23
    #1

    I'm trying to customize a PageIndicator as described here:

    http://doc.qt.io/qt-5/qtquickcontrols2-customize.html#customizing-pageindicator

    but the very same code running on Qt5.7.0 leads to:

    ReferenceError: currentIndex is not defined

    Any idea about?

    EDIT:

    Well, the help page of PageIndicator says:

    The following properties are available in the context of each delegate:
    index : int The index of the item
    pressed : bool Whether the item is pressed

    so it seems currentIndex is not available. But how to know if it is actually the current item? And why the example uses this non-existent attached property?

    EDIT2:
    as workaround I can access the currentIndex property using a reference to the PageIndicator object:

    
    PageIndicator {
        id: myPageInd
        count: 5
        currentIndex: 2
    
        delegate: Rectangle {
            implicitWidth: 8
            implicitHeight: 8
    
            radius: width / 2
            color: "#21be2b"
    
            opacity: index === myPageInd.currentIndex ? 0.95 : pressed ? 0.7 : 0.45
    
            Behavior on opacity {
                OpacityAnimator {
                    duration: 100
                }
            }
        }
    }
    

    Anyway it seems not what Qt developers had in mind.

    1 Reply Last reply
    1
    • J Offline
      J Offline
      jpnurmi
      wrote on 7 Jul 2016, 06:52 last edited by
      #2

      Thanks for bringing it up. We'll update the docs.

      It works without an explicit ID if the custom PageIndicator is in its own .qml file, which is the case for the file where the snippet is extracted from. However, if the PageIndicator is customized inline in a tree of other objects, you'll need to supply an ID since you can't rely on the context.

      M 1 Reply Last reply 8 Jul 2016, 07:57
      1
      • J jpnurmi
        7 Jul 2016, 06:52

        Thanks for bringing it up. We'll update the docs.

        It works without an explicit ID if the custom PageIndicator is in its own .qml file, which is the case for the file where the snippet is extracted from. However, if the PageIndicator is customized inline in a tree of other objects, you'll need to supply an ID since you can't rely on the context.

        M Offline
        M Offline
        Mark81
        wrote on 8 Jul 2016, 07:57 last edited by
        #3

        @jpnurmi Thanks for the clarification!

        1 Reply Last reply
        0

        1/3

        7 Jul 2016, 06:15

        • Login

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