-
QCoreApplication
How do you write a console application?
With GUI application I usually write a main.cpp with the code
QApplication app(argc, argv);
SimpleGUI *ai = new SimpleGUI;
ai->show();
return app.exec();
and then I only have to concentrate on the SimpleGUI class. But what do I do with a console application?
Is it just me, or shouldn't there be more short simple examples in the Qt documentation?
-
Re: QCoreApplication
But you just offered the answer.
With QCoreApplication, which is not part of QtGui, but part of the QtCore module.
You can use any Qt class that you can think of and is not part of QtGui, such as the stream classes, device I/O classes, timers, the xml support, the networking module, etc.
Regards
-
Re: QCoreApplication
So
QCoreApplication app(argc, argv);
SimpleGUI *ai = new SimpleGUI;
ai->dostuff();
return app.exec();
But if doStuff is not returning control back to the app.exec() command? What then?
-
Re: QCoreApplication
But I thought you wanted a console application.
What is the point of showing a GUI in a console app? Or you want to have both a GUI and a console on the screen, as part of your app?
-
Re: QCoreApplication
Oh, sorry, it shouldn't be SimpleGUI, it should be something "SimpleClass". No GUI att all.
-
Re: QCoreApplication
Oh, then it is OK.
But don't forget that in console mode you must( sometimes ) make good use of the arguments passed to your app.
It will work.
I assume ai->doStuff() is a wrapper for more complicated stuff.
A Qt console app is not much different than a standard C++ console app.
Regards