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

ListView indexAt Issue

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 205 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.
  • C Offline
    C Offline
    chung
    wrote on last edited by
    #1

    Hi all,
    I meet an issue with listView indexAt when LayoutMirroring.enabled: true

    LayoutMirroring.enabled: true -> indexAt return -1

    Do you have an idea how i can resolve this ?

    (If I change LayoutMirroring.enabled: false , it is OK)

    import QtQuick 2.12
    import QtQuick.Window 2.12

    Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    LayoutMirroring.enabled: true
    LayoutMirroring.childrenInherit: true
    property alias listView: listView
    
    
    ListView { // PageDots
        id: listView
        width: 250; height: 100
        snapMode: ListView.SnapOneItem
        orientation: Qt.Horizontal
    
        model: 3
        delegate: Item {
            width: 50; height: 50
            Text {
                text: index
                font.pixelSize: 0.9 * listView.height
                anchors.centerIn: parent
            }
    
        }
    
    }
    MouseArea {
        id: mouseArea
        anchors.fill: parent
        onClicked: {
            console.log("indexAt(0) : "+listView.indexAt(0,0));
            console.log("indexAt(200)  : "+listView.indexAt(200,0));
            console.log("indexAt(400) : "+listView.indexAt(400,0));
            console.log("indexAt(600) : "+listView.indexAt(600,0));
        }
    }
    

    }

    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