Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Getting event filter to configure flags on qApp as global helper



  • Hey

    I'm I've set global event filter on my app :

        QApplication a(argc, argv);
        a.installEventFilter(icEventMonitor::EM()); // this can be controlled by a flag.
    

    And set this routing inside my eventFilter() function to handle some selection changes/macros when user press shift/ctrl/mouse press/release etc.

        switch (eventType) {
            case QEvent::MouseButtonPress: {
                mInputManager->handleEventMouseButtonPress(static_cast<QMouseEvent *>(event));
                break;
            }
    
            case QEvent::KeyPress: {
                mInputManager->handleEventKeyPress(static_cast<QKeyEvent *>(event));
                break;
            }
    
        }
    
        bool v = QObject::eventFilter(object, event);
    
        switch (eventType) {
            case QEvent::MouseButtonRelease: {
                mInputManager->handleEventMouseButtonRelease(static_cast<QMouseEvent *>(event));
                break;
            }
            case QEvent::KeyRelease: {
                mInputManager->handleEventKeyRelease(static_cast<QKeyEvent *>(event));
                break;
            }
        }
    

    The issue I'm having is that when user release mouse button. This event here runs till end, unselects the mouse press flag and then notifives the object of change. Where as I though that by doing bool v = QObject::eventFilter(object, event); I can control when I notify widget of event change and then what action to perform post event.

    This class is meant to allow for holding shift, changing widgets/etc etc and still retain the selection flag/macro. Right now the mouse release event flags macro as "de-clicked" and then when widget gets it it has incorrect macro status as it should be as clicked/etc...

    Any ideas how to handle this eventFilter to allow for preWidget action - widgetAction - postWidgetAction workflow?

    TIA


Log in to reply