PDA

View Full Version : Writing a Qt console application



sashoalm
22nd November 2009, 10:05
Hi, this is my first post here,

My question is about console apps, when I start a new console application project in Qt Creator I get a main function like this:

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

printf("Hello world!");

return a.exec();
}

and when I run the app, it never exits. It seems to hang at a.exec(). What's happening?

lasher
22nd November 2009, 10:21
Hi

Read this

http://doc.trolltech.com/4.5/qcoreapplication.html#exec

Greetings

sashoalm
22nd November 2009, 19:57
Hi,

Thanks for the reply. But should I use the "return a.exec()" statement, or should I just change it to "return 0"? The link you provided says a.exec() is used to enable event handling, so I guess I don't really need it, because my program is a console app, so I have no GUI and don't need event handling.

Can you point me to a good tuturial for writing a console app with Qt Creator?

nish
23rd November 2009, 12:17
i think qt creator comes with a new project wizard which generates a skeleton appliction for console

Mudali
7th February 2011, 12:26
Writing a proposal can be a tedious job but if you know the steps, it will be simple. Proposal reason is to convey information and must instill a favorable attitude toward that information and toward the company communicating it.

Tomasz
7th February 2011, 12:43
Thanks for the reply. But should I use the "return a.exec()" statement, or should I just change it to "return 0"?

Just change it to "return 0;" and It should work. Look at that thread: http://www.qtcentre.org/threads/36205-Console-application-exit-application-and-order-of-code. I had the same problem.

best regards
Tomasz

nish
7th February 2011, 18:42
Writing a proposal can be a tedious job but if you know the steps, it will be simple. Proposal reason is to convey information and must instill a favorable attitude toward that information and toward the company communicating it.

Are you a bot?