Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. void MainWindow::mouseMoveEvent ( QMouseEvent * e )
Forum Updated to NodeBB v4.3 + New Features

void MainWindow::mouseMoveEvent ( QMouseEvent * e )

Scheduled Pinned Locked Moved Solved General and Desktop
qtexteditqtableviewmouseevent
5 Posts 3 Posters 3.1k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cdcc0606
    wrote on 25 Apr 2016, 09:37 last edited by
    #1

    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)?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 25 Apr 2016, 21:40 last edited by
      #2

      Hi,

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • E Offline
        E Offline
        elveatles
        wrote on 25 Apr 2016, 22:57 last edited by elveatles
        #3

        @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.

        1 Reply Last reply
        0
        • C Offline
          C Offline
          cdcc0606
          wrote on 26 Apr 2016, 06:19 last edited by
          #4

          @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.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 26 Apr 2016, 07:24 last edited by
            #5

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

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0

            1/5

            25 Apr 2016, 09:37

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved