QML - ListModel



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



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



  • Try to use it with your view delegate



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



  • 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???


  • [quote author="Vijay Bhaska Reddy" date="1309622310"]You can not have a MouseArea inside your ListElement. The only way you should do it is inside the delegate item.[/quote]

    Can you give me an example? :D



  • @ import QtQuick 1.0

    ListModel {
    id: myListModel
    ListElement {
    name: "Bill Smith"
    number: "555 3264"
    }
    ListElement {
    name: "John Brown"
    number: "555 8426"
    }
    ListElement {
    name: "Sam Wise"
    number: "555 0473"
    }
    }

    import QtQuick 1.0

    ListView {
    width: 180; height: 200

     model: myListModel
     delegate: Text {
         text: name + ": " + number
         MouseArea {
         /// add your mouse area code here...
         }
     }
    

    @



  • [quote author="Vijay Bhaska Reddy" date="1309622586"]@ import QtQuick 1.0

    ListModel {
    id: myListModel
    ListElement {
    name: "Bill Smith"
    number: "555 3264"
    }
    ListElement {
    name: "John Brown"
    number: "555 8426"
    }
    ListElement {
    name: "Sam Wise"
    number: "555 0473"
    }
    }

    import QtQuick 1.0

    ListView {
    width: 180; height: 200

     model: myListModel
     delegate: Text {
         text: name + ": " + number
         MouseArea {
         /// add your mouse area code here...
         }
     }
    

    @

    [/quote]

    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. :(


Log in to reply
 

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