zoukankan      html  css  js  c++  java
  • 160308_Helloworld_Console Application

    1、建立Qt Console Application模板

    //Qt4.8
    #include <QCoreApplication> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); return a.exec(); }

    关于QCoreApplication库 官方解释如下:

      The QCoreApplication class provides an event loop for console Qt applications.

      This class is used by non-GUI applications to provide their event loop. For non-GUI application that uses Qt, there should be exactly one   QCoreApplication object. For GUI applications, see QApplication.【控制台应用,QCoreApplication提供事件循环机制,管理应用程序所有资源;GUI应用,采用QApplication】

    QCoreApplication主要功能如下:

      QCoreApplication contains the main event loop, where all events from the operating system (e.g., timer and network events) and other sources are processed and dispatched. It also handles the application's initialization and finalization, as well as system-wide and application-wide settings.

      具体的可参考官方链接:

      http://doc.qt.io/qt-5/qcoreapplication.html

    2、确定QString对象,并使用QDebug类对其进行调试输出

    #include <QCoreApplication>
    #include <QDebug>
    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);  //创建QCoreApplication 对象,用于管理程序资源
        QString mstr="helloworld";
        qDebug()<<mstr;

    return a.exec(); //程序进入事件循环状态,等待用户的动作,能够生成相应事件 }

    总结:

    1)利用控制台应用程序省略了GUI界面的其他内容干扰,便于Qt类的学习和认识,便于对Qt机制的认识。

    2)使用QDebug类,便于运行调试

    问题:

    1)QCoreApplication的运行机制如何?

    2)QObject的含义?

  • 相关阅读:
    Qt学习之路: 国际化(上)
    【Qt】测测你对Qt的了解–Qt工具知多少
    Scade 学习
    SCADESuite嵌入式软件基于模型的开发
    NeHe OpenGL教程 第四十四课:3D光晕
    NeHe OpenGL教程 第四十三课:FreeType库
    NeHe OpenGL教程 第四十二课:多重视口
    NeHe OpenGL教程 第四十一课:体积雾气
    NeHe OpenGL教程 第四十课:绳子的模拟
    78.员工个人信息保镖页面 Extjs 页面
  • 原文地址:https://www.cnblogs.com/zhrong/p/5252959.html
Copyright © 2011-2022 走看看