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. [Solved] Listview and Mousearea and setting current index
QtWS25 Last Chance

[Solved] Listview and Mousearea and setting current index

Scheduled Pinned Locked Moved QML and Qt Quick
10 Posts 2 Posters 2.6k 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.
  • patrikdP Offline
    patrikdP Offline
    patrikd
    wrote on last edited by
    #1

    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
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      What is navigation ? Is it a Component ?

      157

      1 Reply Last reply
      0
      • patrikdP Offline
        patrikdP Offline
        patrikd
        wrote on last edited by
        #3

        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
        0
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          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
          0
          • patrikdP Offline
            patrikdP Offline
            patrikd
            wrote on last edited by
            #5

            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
            0
            • p3c0P Offline
              p3c0P Offline
              p3c0
              Moderators
              wrote on last edited by
              #6

              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
              0
              • patrikdP Offline
                patrikdP Offline
                patrikd
                wrote on last edited by
                #7

                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
                0
                • patrikdP Offline
                  patrikdP Offline
                  patrikd
                  wrote on last edited by
                  #8

                  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
                  0
                  • patrikdP Offline
                    patrikdP Offline
                    patrikd
                    wrote on last edited by
                    #9

                    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
                    0
                    • p3c0P Offline
                      p3c0P Offline
                      p3c0
                      Moderators
                      wrote on last edited by
                      #10

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

                      157

                      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