How to track pointer when is passing trough a button?



  • 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 ;)



  • 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



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



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


Log in to reply
 

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