寒假学习 第一天 (QT学习)

寒假学习 第一天 


编辑器Qt Creator

一、入门

1.手动布局

QHBoxLayout     平布布局
QVBoxLayout      垂直布局

QLabel                 标签
QLineEdit        可以编辑的标签
QPushButton   按钮

#include<QApplication>
#include<QLineEdit>
#include<QPushButton>
#include<QLabel>
#include<QWidget>
#include<QHBoxLayout>
#include<QVBoxLayout>

int main(int argc, char **argv)
{
    QApplication app(argc,argv);
    QLabel *infoLable = new QLabel;
    QLabel *cmdLabel = new QLabel;
    QLineEdit *cmdLineEdit = new QLineEdit;

    QPushButton *submitButton =new QPushButton;
    QPushButton *cancelButton =new QPushButton;
    QPushButton *browserButton =new QPushButton;

    infoLable->setText("Plase input commad");
    cmdLabel->setText("Open:");

    cmdLineEdit->clear();
    submitButton->setText("Submit");
    cancelButton->setText("Cancel");
    browserButton->setText("brower");

    QHBoxLayout *cmdLayout =new QHBoxLayout;
    cmdLayout->addWidget(cmdLabel);
    cmdLayout->addWidget(cmdLineEdit);

    QHBoxLayout *buttonLayout =new QHBoxLayout;
    buttonLayout->addWidget(submitButton);
    buttonLayout->addWidget(cancelButton);
    buttonLayout->addWidget(browserButton);

    QVBoxLayout *mainLayout =new QVBoxLayout;
    mainLayout->addWidget(infoLable);
    mainLayout->addLayout(cmdLayout);
    mainLayout->addLayout(buttonLayout);

    QWidget *window =new QWidget;
    window->setLayout(mainLayout);
    window->setWindowTitle("Runing..");
    window->show();

    return app.exec();



    return 0;
}

手动编译 

进入文件的目录运行
localhost first # qmake -project
localhost first # qmake 
localhost first # make
 
 
 
 
就会在目录下生成可执行文件

2.用Qt Creator 布局

打开  界面文件  xxx.cui
就可以看到很多东西,自己托进去。

3.设定窗口大小不可改

到构造函数中 加入
this->setMaximumSize(442,229);
this->setMinimumSize(442,229);
把最大最小的尺寸设置成一样就可以了




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值