Querying the event loop



  • Hi,

    For this application we're developing, we have a pretty "noisy" event loop. Even to the point where we suspect it will "choke up".
    Necessary or not, is not really the discussion here. What I would like to know if there is a way to query the event loop, to see if there are events "queued" and especially, how many..

    Kind Regards,

    Peter M. Groen


  • Moderators

    @pgroen Hi! You can get the number of the currently pending events of the application's main event loop like this:

    #include "mainwindow.h"
    #include <QApplication>
    #include <QDebug>
    
    extern uint qGlobalPostedEventsCount(); // from qapplication.cpp
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w;
        w.show();
    
        qDebug() << qGlobalPostedEventsCount();
    
        return a.exec();
    }
    

Log in to reply
 

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