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

Find the source of a WindowDeactivate event



  • Hello,
    for some reason in my application I am getting a WindowDeactivate event on the mainwindow which is causing it to lose focus.
    I am trying to track where it's coming from. For that I installed an event filter on the application and printed the stack but it is the typical event filter stack that doesn't give much information.

    How can I find the culprit of making my application lose focus?

    Regards


  • Moderators

    @allopis
    attach with a debugger and inspect the stacktrace at the time the event occurs?



  • I can inspect when the event is being processed, by the event loop, but it provides no useful information because I cannot see how it got there. I can see this type of stack when the event is being processed:

    module::FocusDebug::eventFilter(QObject*, QEvent*)
    QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*)
    QApplicationPrivate::notify_helper(QObject*, QEvent*)
    QApplication::notify(QObject*, QEvent*)
    module::Application::notify(QObject*, QEvent*)
    QCoreApplication::notifyInternal(QObject*, QEvent*)
    QApplication::setActiveWindow(QWidget*)
    QApplication::x11ProcessEvent(_XEvent*)
    
    g_main_context_dispatch
    ) [0x34c4844d08]
    g_main_context_iteration
    QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>)
    
    QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>)
    QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>)
    QCoreApplication::exec()
    module::GelApplication::exec()
    
    module::main(module::ApplicationCreator&, int, char**)
    module::main(int, char**)
    

    As you can see, the stack can show the information about when the event is being processed but not how it got into the event queue


  • Moderators

    @allopis said in Find the source of a WindowDeactivate event:

    QApplication::setActiveWindow(QWidget*)

    what is the widget paramater here

    QApplication::x11ProcessEvent(_XEvent*)

    what is the type of the event here


Log in to reply