How do I create a simple Qt console application in C++?

前端 未结 7 1043
别那么骄傲
别那么骄傲 2020-11-28 22:06

I was trying to create a simple console application to try out Qt\'s XML parser. I started a project in VS2008 and got this template:

int main(int argc, char         


        
相关标签:
7条回答
  • 2020-11-28 22:51

    I managed to create a simple console "hello world" with QT Creator

    used creator 2.4.1 and QT 4.8.0 on windows 7

    two ways to do this

    Plain C++

    do the following

    1. File- new file project
    2. under projects select : other Project
    3. select "Plain C++ Project"
    4. enter project name 5.Targets select Desktop 'tick it'
    5. project managment just click next
    6. you can use c++ commands as normal c++

    or

    QT Console

    1. File- new file project
    2. under projects select : other Project
    3. select QT Console Application
    4. Targets select Desktop 'tick it'
    5. project managment just click next
    6. add the following lines (all the C++ includes you need)
    7. add "#include 'iostream' "
    8. add "using namespace std; "
    9. after QCoreApplication a(int argc, cghar *argv[]) 10 add variables, and your program code..

    example: for QT console "hello world"

    file - new file project 'project name '

    other projects - QT Console Application

    Targets select 'Desktop'

    project management - next

    code:

        #include <QtCore/QCoreApplication>
        #include <iostream>
        using namespace std;
        int main(int argc, char *argv[])
        {
         QCoreApplication a(argc, argv);
         cout<<" hello world";
         return a.exec();
         }
    

    ctrl -R to run

    compilers used for above MSVC 2010 (QT SDK) , and minGW(QT SDK)

    hope this helps someone

    As I have just started to use QT recently and also searched the Www for info and examples to get started with simple examples still searching...

    0 讨论(0)
提交回复
热议问题