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. Circular ListView/ PathView

Circular ListView/ PathView

Scheduled Pinned Locked Moved QML and Qt Quick
pathviewmodellistview
1 Posts 1 Posters 1.9k 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.
  • H Offline
    H Offline
    helenebro
    wrote on 19 Aug 2015, 13:18 last edited by
    #1

    Hi,
    I have a ListView where the current Index is increment/decrement when I press Key_Right/Key_Left.
    If the current index is the last, I would like when if press key right the new current index be 0.
    I have tried with a PathView but my problem is that spacing between each item is the same but I have item with several width.
    This is my QML :

    Window {
        visible: true
        width: 500
        height: 500
        Rectangle{
            anchors.fill: parent
            id: myView
            PathView {
                id:myList
                currentIndex: model/2
                anchors.fill: parent
                property int widthAllList: (widthItemSelect+widthItemNotSelect*(model-1))
                property int widthItemSelect: 150
                property int widthItemNotSelect: 50
                anchors.horizontalCenter: parent.horizontalCenter
                preferredHighlightBegin: 0.5
                preferredHighlightEnd: 0.5
                model: 10
                delegate: Rectangle {
                    color:"#bbbbbb"
                    border.color: "black"
                    anchors.verticalCenter: parent.verticalCenter
                    property bool isCurrentRemote: myList.currentIndex == index
                    width: isCurrentRemote? myList.widthItemSelect: myList.widthItemNotSelect;
                    height:isCurrentRemote? myList.widthItemSelect: myList.widthItemNotSelect
                    Text { text : index; anchors.centerIn: parent}
                }
                path: Path {
                    id:myPath
                    startX: (myView.width-myList.widthAllList)/2
                    startY: myView.height/2
                    PathLine { x: myPath.startX+myList.widthAllList; y:myView.height/2 }
                }
                focus: true
                Keys.onLeftPressed: decrementCurrentIndex()
                Keys.onRightPressed: incrementCurrentIndex()
            }
        }
    }
    

    The problem is the the currentIndex+1 and currentIndew-1 is too close of the current index.
    I have :

           -----
     --  -|     |-  -- 
    |  || |     | ||  |
     --  -|     |-  -- 
           -----
    

    and I would like :

             -----
     --  -- |     | --  -- 
    |  ||  ||     ||  ||  |
     --  -- |     | --  -- 
             -----
    

    If I use ListView, I have the right display but the behavior is wrong.
    How can I solve my problem ?

    Thank you for your help.

    1 Reply Last reply
    0

    1/1

    19 Aug 2015, 13:18

    • Login

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