Important: Please read the Qt Code of Conduct -

Qt 5.2 built with Glib support under OS X - event loop doesn't work

  • Hi,

    I have built Qt 5.2.1 with Glib support under OS X 10.9. Here's a test code:

    #include <iostream>
    #include <glib.h>
    #include <QApplication>

    using namespace std;

    static QApplication * qapp;

    static int idle (void)
    cout << "Idle callback called" << endl;
    cout << "Quitting QApplication" << endl;

    qapp->quit ();
    return G_SOURCE_REMOVE;


    int main (void)
    cout << "Creating QApplication" << endl;

    int dummy_argc = 0;
    qapp = new QApplication (dummy_argc, 0);
    cout << "Adding idle callback" << endl;
    g_idle_add ((GSourceFunc) idle, 0);
    cout << "Starting QApplication" << endl;
    qapp->exec (&#41;;
    cout << "QApplication finished" << endl;
    cout << "Cleaning up" << endl;
    delete qapp;
    qapp = 0;
    cout << "All done" << endl;
    return 0;


    This code works perfectly under Linux, callback is being called. Unfortunately, it doesn't work under OS X... unless you replace QApplication with QCoreApplication, then it works... I want to build a UI interface, so I have to use QApplication. Any idea why it doesn't work as expected?

    Best regards,


    Same problem with Qt 5.3.0.

Log in to reply