QAxWidget losing Mouse Wheel



  • Hi,

    I have created an app using an using the QAxWidget to wrap an activeX object. This is working generally well. I have an issue that when I minimize the application, activate a different application, or simply click outside of the application, the activeX object no longer receives the mouse wheel. All other mouse events seem to work. Oddly enough, if I do this a second time, the activeX object receives the mouse wheel. I have put a trace in the event handling of the widget, and here is what I see:

    1. Starting in a good state, I use the mouse wheel and the activeX object responds.
      (no events)
    2. I click outside my application.
      (no events)
    3. I Click on my application again.
      MouseButtonPress (2)
      MouseButtonRelease (3)
    4. I use the mouse wheel, and the active X object does NOT respond.
      Wheel (31)
      Wheel (31)
      Wheel (31)
    5. I click outside my application again
      WindowDeactivate (25)
    6. I Click on my application again.
      MouseButtonPress (2)
      MouseButtonRelease (3)
    7. I use the mouse wheel and the activeX object responds.
      (no events)
    8. I click outside my application.
      (no events)

    ETC... I can repeat this process again and again.

    The one thing I see differently, is that to make the activeX object regain the mouse wheel, there is an event of "WindowDeactivate " when I click outside of my application. I do not know why this does not occur each time, and I have not been able to force this event to occur every time.

    I have found some similar bug reports:
    https://bugreports.qt.io/browse/QTBUG-15573
    https://bugreports.qt.io/browse/QTBUG-40320

    Thanks for taking a look!

    Edit: I am running on windows 7 enterprise with service pack 1.
    Using:
    Visual Studio 2015 Version 14.0.25431.01 update 3
    Qt 5.7 32-bit (msvc)



  • I will reply to my own thread. Of course, after trying so many different things and it not working, I posted on this forum. Within 30 minutes I found a solution (work around).

    Here it is:

    We have a QWidget subclassed to have a QAxWidget as a member, so what I did was re-implement the event() handling to capture the Wheel event (which it shouldn't get as the overlaid ActiveX object should handle it), and when it does get this event, it would shuffle the focus around to ensure the QAxWidget gets re-focused.

    bool MyWidget::event(QEvent * e)
    {
       QEvent::Type type = e->type();
       switch (type)
       {
       case QEvent::Wheel:
          setFocus();
          clearFocus();
          m_axWidget->setFocus();
          break;
       default:
          break;
       }
       return QWidget::event(e);
    }
    

Log in to reply
 

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