Results 1 to 6 of 6

Thread: QCoreApplication

  1. #1
    Join Date
    Feb 2006
    Posts
    209
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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?

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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

  3. #3
    Join Date
    Feb 2006
    Posts
    209
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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?

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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?

  5. #5
    Join Date
    Feb 2006
    Posts
    209
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QCoreApplication

    Oh, sorry, it shouldn't be SimpleGUI, it should be something "SimpleClass". No GUI att all.

  6. #6
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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

Similar Threads

  1. Use of QCoreApplication
    By moowy in forum Qt Programming
    Replies: 8
    Last Post: 18th May 2007, 08:33
  2. QTcpServer in a QCoreApplication
    By xgoan in forum Qt Programming
    Replies: 1
    Last Post: 23rd March 2007, 10:19
  3. QCoreApplication!!!!
    By fellobo in forum Qt Programming
    Replies: 6
    Last Post: 17th January 2007, 00:56
  4. QCoreApplication And QSqlDatabase
    By ball in forum Qt Programming
    Replies: 1
    Last Post: 24th May 2006, 07:58
  5. QCoreApplication question
    By barnabyr in forum Newbie
    Replies: 5
    Last Post: 24th March 2006, 19:38

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.