您的位置:首页 > 编程语言 > Qt开发

QtCreator 用纯代码编写应用程序与命令行编译

2014-07-14 16:40 218 查看
添加空程序添加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 guigreaterThan(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 -projectqmakemake

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: