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. How to track pointer when is passing trough a button?
Qt 6.11 is out! See what's new in the release blog

How to track pointer when is passing trough a button?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 1.8k Views 1 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.
  • L Offline
    L Offline
    Leon
    wrote on last edited by
    #1

    I want to make a settings dialog, like vlc's settings dialog.
    So what i want is to have some buttons and a stackedwidget.. when u press button 1 it shows page 1 of stackedwidget, button 2 page 2 and goes on.. the buttons are flat and checkable.
    My problem is when the pointer is at the button i want to make the button no flat, and when you move the pointer out of the button it becomes flat again.. ( if you don't know what i mean, see vlc settings or tell me to record a video )...

    It has to be something with mousetracking but i am not really familiar to it..i saw the class reference but it doesn't help me in what i want to do
    thanks for any answer, Leon ;)

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      Oke, for the QPushButton to change shape you need the setMouseTracking() enabled in the widget. This enables you to follow the mouse even when no button is pressed. Then check out the void QWidget::mouseMoveEvent ( QMouseEvent * event ) [virtual protected] function and check out the current mouse position with QMouseEvent::pos()
      Never tried it myself, but might give a starting point.
      greetz

      Greetz, Jeroen

      1 Reply Last reply
      0
      • L Offline
        L Offline
        Leon
        wrote on last edited by
        #3

        So at the header file i added these:
        @class QMouseEvent;
        ....
        protected:
        void mouseMoveEvent(QMouseEvent *mouseEvent);@

        at the source file i added this
        @void preferences::mouseMoveEvent(QMouseEvent *mouseEvent)
        {
        cout << "message" << endl;
        }@

        isn't it suppose to show a message everytime the pointer changes it's position? instead it does nothing..

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          I think you are looking for monitoring the [[doc:QHoverEvent]].

          1 Reply Last reply
          0

          • Login

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