Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    [Solved] Listview and Mousearea and setting current index

    QML and Qt Quick
    2
    10
    1916
    Loading More Posts
    • 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.
    • patrikd
      patrikd last edited by

      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

      1 Reply Last reply Reply Quote 0
      • p3c0
        p3c0 Moderators last edited by

        Hi,

        What is navigation ? Is it a Component ?

        157

        1 Reply Last reply Reply Quote 0
        • patrikd
          patrikd last edited by

          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

          1 Reply Last reply Reply Quote 0
          • p3c0
            p3c0 Moderators last edited by

            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.

            157

            1 Reply Last reply Reply Quote 0
            • patrikd
              patrikd last edited by

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

              1 Reply Last reply Reply Quote 0
              • p3c0
                p3c0 Moderators last edited by

                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 ?

                157

                1 Reply Last reply Reply Quote 0
                • patrikd
                  patrikd last edited by

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

                  1 Reply Last reply Reply Quote 0
                  • patrikd
                    patrikd last edited by

                    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

                    1 Reply Last reply Reply Quote 0
                    • patrikd
                      patrikd last edited by

                      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

                      1 Reply Last reply Reply Quote 0
                      • p3c0
                        p3c0 Moderators last edited by

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

                        157

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post