console application using Qt

Amit Upadhyay upadhyay at
Fri Oct 4 17:14:07 BST 2002

On Fri, 4 Oct 2002, Berge, Harry ten wrote:
~ Is it possible to make a console application where I use Qt functionality?
~ Because Qt needs an QApplication object and you have to call
~ QApplication::exec. But if you don't have widgets then 'exec' doesn't do
~ anything. So I want my own loop (while (1) or something like that) where I
~ can use for example QString.

You are correct, QApplication loop will start if you exec on some widget,
but then you want non GUI library I guess.

---> a.cpp

#include <qstring.h>
#include <iostream.h>

int main(void){
        QString str = "Hello World!";
        cout << str.latin1() << endl;

$ gcc a.cpp -I/usr/lib/qt3/include -lqt [if on command line]

else in kdevelop[and the project type was Console CPP app], put
-I/usr/lib/qt3/include in Project->Options->Compiler Options->Flags and
Warnings->C++ Compiler Flags Field and select qt in
Project->Options->Linker Options.

This would not be the right way of doing things, as you are hard coding
the location of qt header, and your program may not compile on other

So I prefer to set my project to KDE Normal and remove things I dont need.


Amit Upadhyay

ps: I was about to send when I realised I should use -I$QTDIR/include. Try
it, it may work on your system too.. 

to unsubscribe from this list send an email to kdevelop-request at with the following body:
unsubscribe »your-email-address«

More information about the KDevelop mailing list