Qt控制台和带窗口的区别

如题所述

  选择创建控制台生成以下代码
  #include <QtCore/QCoreApplication>
  int main(int argc, char *argv[])
  {
  QCoreApplication a(argc, argv);
  return a.exec();
  }
  .pro文件如下
  QT += core
  QT -= gui
  TARGET = test1
  CONFIG += console
  CONFIG -= app_bundle
  TEMPLATE = app
  SOURCES += main.cpp
  如果要想变成带窗口的程序需要做如下改变
  QCoreApplication a(argc, argv);
  变成
  QApplication a(argc, argv);
  QCoreApplication
  是控制台的Application
  QApplication
  是带窗口的Application
  最后变化如下
  #include <QtGui/QApplication>
  #include <QtCore>
  #include <QWebView>
  #include <QWebFrame>
  #include <QThread>
  #include <QUrl>
  int main(int argc, char *argv[])
  {
温馨提示:答案为网友推荐,仅供参考
相似回答