views:

84

answers:

2

Are there any Qt Console Application example/tutorial?

I am looking for one that utilize the event loop. Most of the examples I have seen does not use the loop.

+1  A: 

Look e.g. here. Basically all you need is to run an instance of QCoreApplication in main().

Taken from the link above:

#include <QCoreApplication>

int main(int argc, char *argv[])
{
    QCoreApplication app(argc, argv[]);

    // (1) We *could* write a whole application
    // here if it doesn't need event handling.

    // (2) Set up something that will trigger events

    return app.exec();
}

app.exec() starts the event loop of the app. This is the event loop for all QObejcts that have app as a parent, which you have to create before app.exec(), because this function exits only when the program quits.

gre
+1  A: 

Simple console ftp client with event loop.

Sources

Ekimov Alexander