how to use highlight element



  • I am making a telephome gui application using qml, I want to know how to use highlight element to highlight the elements of the dynamic list. The new element in the list must get highlighted. below is my source code.
    ListView{
    id:myview
    // model:callmodel
    model:callmodel
    width: mainrect.width
    anchors.bottom: buttonsrow.top
    anchors.bottomMargin: 0
    anchors.top: currentcalldisplay.bottom
    anchors.topMargin: 0
    delegate: mydelegate
    focus:true
    }
    delegate:
    Component{
    id:mydelegate

    Rectangle{
        id:delrec
        property string localcallstate:callstate
        property string localcallnumber:callnumber
        width:mainrect.width
        height: mainrect.height/10
        function getcolor(localcallstate)
        {
            if(localcallstate == "Active")
                return "#22d73a"
            else if(localcallstate == "Hold")
                return "#aa7865"
            else if(localcallstate == "Incoming")
                return "#f910da"
        }
    
        color: getcolor(localcallstate)
        Text {
            id: callstatetexr
            anchors.right:parent.right
            anchors.rightMargin: parent.width/6
            anchors.verticalCenter:delrec.verticalCenter
            text: localcallstate
            font.pointSize: 25
        }
        Text {
            id: callnumbertext
            anchors.left: parent.left
            anchors.leftMargin: parent.width/5
            anchors.topMargin: parent.height/5
            anchors.verticalCenter:delrec.verticalCenter
            text: localcallnumber
            font.pointSize: 25
        }
       focus:true
       MouseArea {
           anchors.fill: parent
           onClicked: myview.currentIndex = index
       }
    }
    

    }

    i want to know the implementation of the highlight element so that the newly entered element in the list will get highlighted.


  • Moderators

    Please wrap your code in code tags to make it easier to read.


Log in to reply
 

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