- 添加空程序
- 添加C++ source file: main.cpp
#include <QApplication>
#include <QDialog>
#include <QLabel>
int main(int argc, char** argv) {
QApplication app(argc,argv);
QDialog w;
QLabel lbl(&w);
lbl.setText("hello,你好!");
w.show();
return app.exec();
}
- 需要界面的QT程序都必须要在,*.pro文件里面加下面的语句
- QT += core gui
- greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
- 避免中文出现乱码
#include <QApplication>
#include <QDialog>
#include <QLabel>
#include <QTextCodec>
int main(int argc, char** argv) {
QApplication app(argc,argv);
QTextCodec::setCodecForLocale(QTextCodec::codecForLocale());
QDialog w;
QLabel lbl(&w);
lbl.setText(QObject::tr("你好!"));
w.show();
return app.exec();
}
- qmake -project
- qmake
- make
QtCreator 用纯代码编写应用程序与命令行编译
最新推荐文章于 2024-06-16 11:11:12 发布