Widgets and mouse events



  • hi
    i need a method that give me some info about the widgets on frames sth. that works with mouse here is a part of my code but i dont know what to write in "if" statements

    void my_qlabel::mousePressEvent(QMouseEvent *ev)
    {
    emit mouse_pressed();
    if()
    {
    //change button background
    }
    else if()
    {
    //change label color
    }
    else if()
    {
    //change textline color
    }
    }

    thank for your help



  • if(ev->button() == Qt::LeftButton)
    {
    //...
    }



  • What Vittal points out is that the QMouseEvent has a list of all available options that could cause the event to be triggered. In the Qt-enum list the normal ones are defined. So, compare the event with the one you need e.g. Qt::LeftButton and so on.
    Greetz.


Log in to reply
 

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