Listview onclick event



  • I have a listview with 5 items, onclicking them results in a rectangle with their properties. The starting point of the rectange is just beside the list. For instance if i clickon 5th element the rectangle is half sunk, as my width and height is limited. I want tat rectangle to start at a higher position: i tried to give x,y values but this does not work. I hope you have got my quesiton. If details are required, I will be more than happy to give them

    Thanks in advance



  • The better way is to encapsulate the rectangle in the element, then set it visible only when necessary, in association with some state, for example.



  • hmm okay.. I will try.. Also, I want a screen behind the rectange which disables the listelement, so that the user is unable to click on the elements. any idea how to go about.?



  • Many way to do the job.
    A Mousearea with a onReleased : {} or, wich is the proper way, using index & currentIndex to set the state of each element.



  • I tried to encapsulate the rectangle but the problem is, its within Component.I cannot alter the x and y inside the component.



  • @// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
    import QtQuick 1.1

    Rectangle {
    id:main
    width: 360
    height: 360

    Component
    {
    id:contactdelegate
    
    Item {
                x: 5
                height: 40
                Row {
                    id: row1
                    spacing: 10
                    Rectangle {
                        width: 40
                        height: 40
                        color: colorCode
                    }
    
                    Text {
                        text: name
                        anchors.verticalCenter: parent.verticalCenter
                        font.bold: true
                    }
                }
    
    
    Text{
        id:t1
    
        text :"HELLO"
    
    
    
    }
    

    }
    }

    ListModel {
        id:listmodel
                ListElement {
                    name: "Grey"
                    colorCode: "grey"
                }
    
                ListElement {
                    name: "Red"
                    colorCode: "red"
                }
    
                ListElement {
                    name: "Blue"
                    colorCode: "blue"
                }
    
                ListElement {
                    name: "Green"
                    colorCode: "green"
                }
            }
    
    
    
    ListView {
        id: list_view1
        x: 27
        y: 62
        clip:true
        width: 110
        height: 160
        delegate: contactdelegate
        model: listmodel
    }
    

    }
    @

    Is it possible for me to have the text "Hello" at the beginning of the main reactange at x,y:0 position??
    Thanks in advance!



  • I know this would be possible if u go outside the component and place it. But u want the text to be within the component.


Log in to reply
 

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