QT常用部件类

一、按钮类

        1、普通按钮(Push Button)

#include <QPushButton>

QPushButton *bt_button; //普通按钮
bt_button = new QPushButton("普通按钮");
connect(bt_button, SIGNAL(clicked(bool)), this, SLOT(xxx(bool)));//绑定信号与槽函数

         2、工具按钮(Tool Button)

#include <QToolButton>

QToolButton *bt_tool;   //工具按钮
bt_tool = new QToolButton;
bt_tool->setText("工具按钮");

         3、单选(Radio Button)

#include <QRadioButton>

QRadioButton *bt_radio = new QRadioButton;
QRadioButton *bt_radio1 = new QRadioButton;

bt_radio = new QRadioButton("单选按钮");
bt_radio1 = new QRadioButton("单选按钮1");

        4、复选(Check Box)

#include <QCheckBox>

QCheckBox *bt_check;    //复选按钮
QCheckBox *bt_check1;   //复选按钮

bt_check = new QCheckBox("复选框");
bt_check1 = new QCheckBox("复选框1");

5、命令连接(Command Link Button)

#include <QCommandLinkButton>

QCommandLinkButton *bt_cmd;//命令按钮

bt_cmd = new QCommandLinkButton("百度");
bt_cmd->setDescription("www.baidu.com");

二、布局类

        1、水平(Horizontal BoxLayout)

#include <QHBoxLayout>

QPushButton *q1 = new QPushButton;
QVBoxLayout *vbox = new QVBoxLayout;

QHBoxLayout *hbox = new QHBoxLayout;
hbox->addWidget(q1);//加入控件
hbox->addLayout(vbox);//加入布局

        2、垂直(Vertical BoxLayout)

#include <QVBoxLayout>

QPushButton *q1 = new QPushButton;
QHBoxLayout *hbox = new QHBoxLayout;

QVBoxLayout *vbox = new QVBoxLayout;
vbox->addWidget(q1);//加入控件
vbox->addLayout(hbox);//加入布局

        3、网格(Grid Layout)

#include <QGridLayout>

QPushButton *q1 = new QPushButton;
QPushButton *q2 = new QPushButton;
QPushButton *q3 = new QPushButton;
QPushButton *q4 = new QPushButton;

QGridLayout *gbox = new QGridLayout;
gbox->addWidget(q1,0,0);//加入控件
gbox->addWidget(q2,0,1);
gbox->addWidget(q3,1,0);
gbox->addWidget(q4,1,1);

 三、输出类

     

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值