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. MouseMoveEvent when scrolling
Forum Update on Monday, May 27th 2025

MouseMoveEvent when scrolling

Scheduled Pinned Locked Moved General and Desktop
qt 5.4.2mousemoveeventscroll
1 Posts 1 Posters 1.2k Views
  • 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.
  • P Offline
    P Offline
    petoknm
    wrote on last edited by SGaist
    #1

    Hi
    I was making some demo application when I realized I was getting mouseMoveEvents when scrolling. The position in the event is the last position of the mouse when it was released. I also made a small video documenting this visually. The code is for simulating waves by the way :D. But I moved the cursor away from the waves and scrolled you can see it generates disturbances in the waves. After a closer inspection I found out that they are getting called with the last position where the mouse was clicked. Is this a correct behaviour? If yes what is wrong with my code(I don't want to get mouse move events when scrolling... Is it a feature or a bug?)?

    class MyGraphicsScene : public QGraphicsScene
    {
    Q_OBJECT
    signals:
    void mouseMoved(QPointF);
    private:
    void	mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent);
    };
    
    void MyGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
    {
    emit mouseMoved(mouseEvent->scenePos());
    mouseEvent->accept(); // Actually I don't know if I should do this, but it doesn't affect this behaviour
    }
    
    
    class Wave1DWidget : public QGraphicsView
    {
    Q_OBJECT
    ...
    MyGraphicsScene scene;
    public slots:
    void sceneMouseMoved(QPointF);
    ...
    }
    
    Wave1DWidget constructor{
    ...
    connect(&scene,SIGNAL(mouseMoved(QPointF)),this,SLOT(sceneMouseMoved(QPointF)));
    ...
    }
    
    void Wave1DWidget::sceneMouseMoved(QPointF pos)
    {
    cout <<pos.x() << ", " << pos.y() << endl;
    ... // handling the move event like setting the height of the wave at that point…
    }
    

    [Edit: added missing coding tags: ```before and after the code SGaist]

    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