Windows Qt编译过程:
1、编写源代码
2、修改环境变量
3、生成工程文件
4、生成Makefile
5、编译
1、cmd进入工程目录
2、qmark -project 生成工程文件
3、修改工程文件,最后一行添加:
QT+=gui widgets
#include <QPushButton>
#include <QHBoxLayout> //水平布局
#include <QVBoxLayout> //垂直布局
#include <QWidget>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel *infoLabel = new QLabel;
QLabel *openLabel = new QLabel;
QLineEdit *cmdLineEdit = new QLineEdit;
QPushButton *commitButton = new QPushButton;
QPushButton *cancelButton = new QPushButton;
QPushButton *browseButton = new QPushButton;
infoLabel->setText("input cmd:");
openLabel->setText("open");
commitButton->setText("commit");
cancelButton->setText("cancel");
browseButton->setText("browse");
QHBoxLayout *cmdLayout = new QHBoxLayout; //水平布局对象
cmdLayout->addWidget(openLabel);
cmdLayout->addWidget(cmdLineEdit);
QHBoxLayout *buttonLayout = new QHBoxLayout;
buttonLayout->addWidget(commitButton);
buttonLayout->addWidget(cancelButton);
buttonLayout->addWidget(browseButton);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(infoLabel);
mainLayout->addLayout(cmdLayout);
mainLayout->addLayout(buttonLayout);
QWidget w;
w.setLayout(mainLayout);
w.show();
w.setWindowTitle("测试");
return app.exec();
}
打开release下的.exe