[Qt-interest] how to create a console application on Mac OS?
Tim Dewhirst
tim at bugless.co.uk
Thu Feb 26 10:03:44 CET 2009
Hello,
James Yan wrote:
> I need a hello world like this with Qt:
> #include <QString>
> //main func
> int main(int argc,char* argv[])
> {
> QString str = "Hello World\n";
> printf("> %s\n",str.toAscii().data());
> return 0;
> }
>
> then i insert a line like following to my .pro file:
> "CONFIG += qt console"
>
> it works all fine on windows, but fail ( or un-normal ) on Mac OS,
> compile is OK, i got a hello.app and can run it, but just do not get a
> "hello world" message in my terminal(bash), is there anything special on
> Mac to creating a console(non-GUI) application with Qt?
If you create a bundle then depending on how you run the application you
may get console output:
* double click on bundle: no output
* from command line: open hello.app: no output
* from console: ./hello.app/Contents/MacOS/hello: output
Or, if you want to avoid creating a bundle in the first place you should
be able to add this option to your .pro file:
CONFIG-=app_bundle
Tim
More information about the Qt-interest-old
mailing list