Listview on Multitouch Device



  • Hello,

    is it possible to use two Listview on a Multitoch device? I use two Listviews, bu it is not possible two scroll simultaneously. Heres a code example:

    Rectangle  {
      width: 480
      height: 272
      visible: true
    
      ListModel {
          id: model1
          ListElement {
              name: "Bill Smith"
              number: "555 3264"
           }
    
          ListElement {
              name: "John Brown"
              number: "555 8426"
          }
          ListElement {
              name: "Sam Wise"
              number: "555 0473"
          }
      }
    
    ListView {
        id: lv1
        anchors.top: parent.top
        anchors.left: parent.left
        anchors.bottom: parent.bottom
        width: 240
    
        model: model1
    
        delegate: Text {
            text: name + ": " + number
        }
    }
    
    ListView {
        id: lv2
        anchors.top: parent.top
        anchors.left: lv1.right
        anchors.right: parent.right
        anchors.bottom: parent.bottom
        width: 240
    
        model: model1
    
        delegate: Text {
            text: name + ": " + number
        }
      }
    }
    

    I'd like to use both ListView Elements simultaneously, but have not found a way to do this.
    Is there a way to do this?

    Best regards
    Martin


  • Moderators

    @winkler3523 I think you will need to use MultiPointTouchArea.



  • Hi,
    you can link the two ListView using the contentY property of Flickable type (which is inherited by ListView)
    That way when you scroll lv1 also lv2 scrolls:

    ListView {
        id: lv2
        anchors.top: parent.top
        anchors.left: lv1.right
        anchors.right: parent.right
        anchors.bottom: parent.bottom
        width: 240
        // add this binding
        contentY: lv1.contentY
    
        model: model1
    
        delegate: Text {
            text: name + ": " + number
        }
    }
    

    Of course they do not scroll independently!!



  • Hi,

    @p3c0: i have used the MultiPointTouchArea in my project, but i have no idea how to use it to scroll the Listviews indepentently. Any suggestions?

    @synasius: it is nessesary to scroll the Listviewss indenpentently so i can not use this apporch.

    regards


  • Moderators

    @winkler3523 Try by binding TouchPoint's y coordinate to contentItem.y of ListView. But it doesn't seem straightforward.



  • Hi,

    thank you. I will give it try, although it seems not that straightforward. I have to check wich TouchPoint is over a listview and use its y coordinate to move the listview.

    I also have seen this patch:
    https://codereview.qt-project.org/#/c/65801/

    It is in the review state. It should solve the problem. I will also try this, because that would be a clean solution.

    thanks
    Martin


  • Moderators

    @winkler3523 Good find. But it seems to be there from ages :) Vote it up.


Log in to reply
 

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