[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: listViewMain

                    delegate: 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


  • Moderators

    Hi,

    What is navigation ? Is it a Component ?



  • Hi p3c0,
    yes its a component within a repeater. i also have two buttons within the listview at the right and left for next end prev. behaviour is the same.
    best,
    patrik


  • Moderators

    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.



  • hi p3c,
    yes thats the correct scenario. and after that, when i scroll by hand once the functionallity for autoscrolling is back.
    thx,
    patrik


  • Moderators

    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,
    os win8.1. behaviour is identic for android. i will try to extract the code and post it.
    thx,
    patrik



  • hi,
    os win8.1. behaviour is identic for android. i will try to extract the code and post it.
    Qt 5.4 and 5.3
    thx,
    patrik



  • 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


  • Moderators

    Glad to hear that it's working now. Happy coding :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.