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. Overriding general CustomWidget::mouseMoveEvent for a specific objects own mouseMoveEvent
QtWS25 Last Chance

Overriding general CustomWidget::mouseMoveEvent for a specific objects own mouseMoveEvent

Scheduled Pinned Locked Moved Unsolved General and Desktop
mousemoveevent
2 Posts 2 Posters 837 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.
  • T Offline
    T Offline
    TGRSM
    wrote on 25 Jul 2022, 14:10 last edited by
    #1

    This is a large complex app, so difficult to break down the code into small chunks for this audience.

    We have a CustomWidget which is used to handle mouse/touch events for most other widgets.

    We have one widget on which the users can either click a button and the button is activated, or they can click and move to move the whole widget.

    On Windows systems this work fine, but testing on Android the button click is not registered and it always goes to the CustomWidget::mouseMoveEvent.

    I think this might possibly be due to a higher touch sampling rate on Android than on Windows. We can if we deliberately try get the Windows app to behave similarly, but on Android we have to be very careful to click the button without moving/nudging the widget. If there is any hint as to what setting can be adjusted to control this that would be helpful.

    widget1.cpp:

    void widget1::mouseMoveEvent(QMouseEvent *e)
    {
    
        qDebug() << "Widget1 MouseMove";
    
        CustomWidget::mouseMoveEvent(e);
    
    }
    

    I added some qDebug to the CustomWidget::mouseMoveEvent method and it shows this gets called directly, bypassing widget1::mouseMoveEvent. This widget1::mouseMoveEvent only gets called if the widget is clicked and dragged some distance.

    How can I set widget1::mouseMoveEvent to be called for every mouseMoveEvent within widget1?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mpergand
      wrote on 25 Jul 2022, 16:00 last edited by mpergand
      #2

      Seems you need to enable mouse tracking for widget1, see:

      void setMouseTracking(bool enable)
      If mouse tracking is switched off, mouse move events only occur if a mouse button is pressed while the mouse is being moved. If mouse tracking is switched on, mouse move events occur even if no mouse button is pressed.

      1 Reply Last reply
      1

      2/2

      25 Jul 2022, 16:00

      • Login

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