一、QT编译

一、修改环境变量

二、生成工程文件

1、qt-cmd进入工程目录
2、 qmake -project 生成工程文件
3、修改工程文件,最后一行添加:
       QT += gui widgets

三、生成makefile

执行命令
     qmake

四、编译工程

mingw32-make
注:如果找不到命令,需要添加环境变量,mingw32-make.exe在Qt5.8.0\Tools\mingw530_32\bin目录下

#include <QApplication>
#include <QLabel>
#include <QLineEdit>
#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("cancel");
    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("running");

    return app.exec();
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值