July 2, 2011

FlyingFish FlyingFish
Lab Rat
37 posts

QML - ListModel

 

Hi! I’ve been trying to use mouseArea in ListElement and have been failing miserably. Is it even possible? Thanks!

7 replies

July 2, 2011

sfjam sfjam
Lab Rat
41 posts

as far as i know,it cann’t define mouse event in ListElevent!

July 2, 2011

Chuck Gao Chuck Gao
Lab Rat
342 posts

Try to use it with your view delegate

 Signature 

Chuck

July 2, 2011

FlyingFish FlyingFish
Lab Rat
37 posts

I can’t do it. I think I’m doing it wrong. :(

July 2, 2011

Vijay Bhaska Reddy Vijay Bhaska Reddy
Lab Rat
399 posts

You can not have a MouseArea inside your ListElement. The only way you should do it is inside the delegate item.

When you say you can not do it..

1) You can not add MouseArea inside ListElement ??? or
2) You can not add MouseArea inside your delegate???

July 2, 2011

FlyingFish FlyingFish
Lab Rat
37 posts
Vijay Bhaska Reddy wrote:
You can not have a MouseArea inside your ListElement. The only way you should do it is inside the delegate item.

Can you give me an example? :D

July 2, 2011

Vijay Bhaska Reddy Vijay Bhaska Reddy
Lab Rat
399 posts

  1.  import QtQuick 1.0
  2.  
  3.  ListModel {
  4.      id: myListModel
  5.      ListElement {
  6.          name: "Bill Smith"
  7.          number: "555 3264"
  8.      }
  9.      ListElement {
  10.          name: "John Brown"
  11.          number: "555 8426"
  12.      }
  13.      ListElement {
  14.          name: "Sam Wise"
  15.          number: "555 0473"
  16.      }
  17.  }
  18.  
  19. import QtQuick 1.0
  20.  
  21.  ListView {
  22.      width: 180; height: 200
  23.  
  24.      model: myListModel
  25.      delegate: Text {
  26.          text: name + ": " + number
  27.          MouseArea {
  28.          /// add your mouse area code here...
  29.          }
  30.      }

July 3, 2011

FlyingFish FlyingFish
Lab Rat
37 posts

Vijay Bhaska Reddy wrote:
  1.  import QtQuick 1.0
  2.  
  3.  ListModel {
  4.      id: myListModel
  5.      ListElement {
  6.          name: "Bill Smith"
  7.          number: "555 3264"
  8.      }
  9.      ListElement {
  10.          name: "John Brown"
  11.          number: "555 8426"
  12.      }
  13.      ListElement {
  14.          name: "Sam Wise"
  15.          number: "555 0473"
  16.      }
  17.  }
  18.  
  19. import QtQuick 1.0
  20.  
  21.  ListView {
  22.      width: 180; height: 200
  23.  
  24.      model: myListModel
  25.      delegate: Text {
  26.          text: name + ": " + number
  27.          MouseArea {
  28.          /// add your mouse area code here...
  29.          }
  30.      }

Damn, I still can’t get it .

I even tried editing this http://projects.developer.nokia.com/QMLTemplates/wiki/WikiStart#accordionlist I need to study more I guess. :(

 
  ‹‹ how to improve qml application program’s speed      how to use qml to cut a part of one picture? ››

You must log in to post a reply. Not a member yet? Register here!