1, first create a file .cpp below a generating application in a disk (F disc)
#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 *cancelBotton = new QPushButton;
QPushButton *browseButton = new QPushButton;
infoLabel->setText("input your cmd ..");
openLabel->setText("open");
commitButton->setText("commit");
cancelBotton->setText("cancel");
browseButton->setText("browse");
QHBoxLayout *cmdLayout = new QHBoxLayout; //水平布局对象
cmdLayout->addWidget(openLabel);
cmdLayout->addWidget(cmdLineEdit);
QHBoxLayout *buttonLayout = new QHBoxLayout;
buttonLayout->addWidget(commitButton);
buttonLayout->addWidget(cancelBotton);
buttonLayout->addWidget(browseButton);
QVBoxLayout *mainLayout = new QVBoxLayout; //全局的垂直布局
mainLayout->addWidget(infoLabel);
mainLayout->addLayout(cmdLayout); //注意是addLayout() 在已经水平的一个组合
mainLayout->addLayout(buttonLayout);
QWidget *w = new QWidget;
w->setLayout(mainLayout);
w->show();
return app.exec();
}
2, open the Qt command prompt
(1), f: // into the F drive
(2), cd cd path F //: \ QMAKE \ qmake
(3), qmake -project // generating projects
(4), use Notepad to open qmake.pro add content to the GUI Widgets = + QT
(5), qmake // generate the makefile
(6), mingw32-make // compiler generates several files to find the release folder can click on the application
Within If Advanced system settings computer properties -> Advanced -> no path QT installed within pash path within the environment variables (system and user variables), it is necessary -> New -> Add to add into the QT path can be a