Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to notify a widget for mouse event?



  • hi,
    i want to create a class that when i bring my mouse to a widget(e.g. qPushButton or qLabel etc.) its color changes or its text becomes bold...
    please help me how can i do that?
    tnx :)



  • do you want a Qwidgets or Qml components

    if Qml components

    @
    Rectangle
    {
    id: button

    width: 30
    height:20
    
        Text {
            id: string
            text: "click me!"
            font.pointSize: 12
            font.family: "KacstBook"
        }
    
    MouseArea
    {
        id:itemmousearea
        anchors.fill: parent
        hoverEnabled: true
        onEntered:{ button.color = "lightblue"}
        onExited: { button.color = "white"}
    }
    

    }
    @



  • that helps thank you :) but could you post Qwidgets???


Log in to reply