void MainWindow::mouseMoveEvent ( QMouseEvent * e )



  • In my mainwindow, I have a function mouseMoveEvent. Each time when it enters in to a bouton, the button changes the backgrouand image. It works fine for all the other widget except for QTextEdit, and QTableView. When the mouse enter into these two zones, the mouse doesn't not detect it's alrealy out of button zone. So the background image of the bouton doesn't change back.
    Is there anything else should I do for these two objects other than setMouseTracking (true)?


  • Lifetime Qt Champion

    Hi,

    Your setup is not really clear. Are you trying to replicate the background change for all widgets ?



  • @cdcc0606

    Have you tried using enterEvent and leaveEvent on each widget instead?

    Another option is to use Qt stylesheets if all you're doing is changing the background image.



  • @elveatles @SGaist
    what I'm doing is just changing the background image, when the mouse is enter into the zone of button HOME. Even if it is not clicked. so here is my code for this part.
    void MainWindow::mouseMoveEvent ( QMouseEvent * e )
    {
    e->accept();
    if(enterBtn(e->pos(),ui->btn_Home))
    {
    ui->btn_Home->setStyleSheet("border-image: url(images/Bouton_Home_Survolle.png);");
    }else
    {
    ui->btn_Home->setStyleSheet("border-image: url(images/Bouton_Home_Normal.png);");
    }
    }
    so it can detect the position of mouse if it is in or out of the button HOME, however, when the mouse if move from the button HOME then entering the QTextEdit or QTableView, it cannot detect it has already out of the button HOME. So i doesn't have my image Bouton_Home_Normal.png. That's all. I don't know what is missed.


  • Lifetime Qt Champion

    Then you should rather use an event filter so you'll only test when there's something currently going on with your button.


Log in to reply
 

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