[Solved] Listview and Mousearea and setting current index
-
hi all,
i have a listview and i also have a navigation which allows directly to set a current index on the listview.
clicking on the nav makes the listview scrolling to the pos of the selected item. this works so far so good.
i now added a mousearea on the listview for listening for doubleclicks, resizing the view to fullscreen.
when i use this doubleclickarea the autoscrolling to the currentindex from navigation doesn't work anymore.
i have to scroll the listview one time by hand and then the autoscrolling works again.
here my listview:
@
ListView {
id: listViewMaindelegate: mainViewDelegate model: pages.pages snapMode: ListView.SnapOneItem; highlightFollowsCurrentItem: true highlightRangeMode:ListView.StrictlyEnforceRange highlightMoveDuration: 1200 orientation: Qt.Horizontal clip: true currentIndex: 0 onCurrentIndexChanged: { console.log("currentIndex changed") } MouseArea { id: doubleClickArea anchors.fill: parent onDoubleClicked: { console.log("doubleclick") if (contentPage.state == "fullscreen") contentPage.state = "regular" else contentPage.state = "fullscreen" } } }//end listViewMain
@
from the navigation i use:
@
listViewMain.currentIndex = targetIndex
@"onCurrentIndexChanged" is called but the listview doesn't move anymore.
any ideas?
thx,
patrik -
Hi,
What is navigation ? Is it a Component ?
-
Trying to understand the senario:
So is it that after you double click, the screen resizes to fullscreen, then when you navigate, it doesnot scroll but the currentIndex changes ?
May be you should post a small complete working example which will explain it. -
Ok. I tried something similar but it works for me. Which Qt Version and OS are you using ?
Or can you post a reduced complete compilable code which will show the problem ? -
Hi p3C0,
i found the reason. at the begining of the resize transistion i called a function to lock the listview with "listview.enabled = false". a script with "enable.listview = true" was called at the end. the listview was correctly enabled but this seemed the reason for stopping of the autoscrolling.
thx for your help,
patrik -
Glad to hear that it's working now. Happy coding :)