QT常用部件类

一、按钮类

        1、普通按钮(Push Button)

#include 

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

         2、工具按钮(Tool Button)

#include 

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

         3、单选(Radio Button)

#include 

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

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

        4、复选(Check Box)

#include 

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

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

5、命令连接(Command Link Button)

#include 

QCommandLinkButton *bt_cmd;//命令按钮

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

二、布局类

        1、水平(Horizontal BoxLayout)

#include 

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

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

        2、垂直(Vertical BoxLayout)

#include 

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

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

        3、网格(Grid Layout)

#include 

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);

 三、输出类

     

你可能感兴趣的:(QT基础入门,windows,qt5,c++,小程序)