Trapping and releasing mouse input



  • I have a widget covering my screen that catches all mouse input. What I want is that when it is clicked, I decide if it should handle the mouse input or allow the mouse input to go through like the widget isn't there.

    I can't just call sendEvent() because I don't know who the input would go to. There are multiple objects underneath the area.

    How can I go about deciding to handle it or just allowing it to pass through?


  • Moderators

    i haven't found a good (Qt only) solution for myself either for this problem.
    The only thing i did which seemed to work is:
    @
    this->hide();
    QWidget* widget = QApplication::widgetAt(mosueEvent->globalPos());
    this->show();
    @
    But this only works for widgets inside your application.



  • Thanks.

    I did the following which seems to work:
    QMouseEvent * pMouse = static_cast<QMouseEvent >(e);
    this->hide();
    QWidget
    widget = QApplication::widgetAt(pMouse->globalPos());
    this->show();
    QApplication::sendEvent(widget, pMouse);


Log in to reply
 

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