一.按钮类:
1.普通按钮:QPushButton;
2.工具按钮:QToolButton ;
3.单选按钮:QRadioButton ;
4.复选按钮:QCheckBox ;
5.命令连接:QCommandLinkButton ;
基本使用方法:widget.cpp
#include "widget.h"
#include <QVBoxLayout>
#include <QDebug>
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
bt_button = new QPushButton("普通按钮");
bt_tool = new QToolButton;
bt_tool->setText("工具按钮");
bt_radio = new QRadioButton("单选按钮");
bt_radio1 = new QRadioButton("单选按钮1");
bt_check = new QCheckBox("复选框");
bt_check1 = new QCheckBox("复选框1");
bt_cmd = new QCommandLinkButton("百度");
bt_cmd->setDescription("www.baidu.com");
//应用
le = new QLineEdit;
le->setEchoMode(QLineEdit::Password);
ck = new QCheckBox("显示密码");
QVBoxLayout *vbox = new QVBoxLayout;
vbox->addWidget(bt_button);
vbox->addWidget(bt_tool);
vbox->addWidget(bt_radio);
vbox->addWidget(bt_radio1);
vbox->addWidget(bt_check);
vbox->addWidget(bt_check1);
vbox->addWidget(bt_cmd);
vbox->addWidget(le);
vbox->addWidget(ck);
setLayout(vbox);
connect(bt_check, SIGNAL(toggled(bool)), this, SLOT(xxx(bool)));
connect(ck, SIGNAL(toggled(bool)), this, SLOT(showpass(bool)));
}
void Widget::showpass(bool x)
{
if(!x)
le->setEchoMode(QLineEdit::Password);
else
le->setEchoMode(QLineEdit::Normal);
}
void Widget::xxx(bool x)
{
qDebug() << x;
}
Widget::~Widget()
{
}
widget.h
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QPushButton>
#include <QToolButton>
#include <QRadioButton>
#include <QCheckBox>
#include <QCommandLinkButton>
#include <QLineEdit>
class Widget : public QWidget
{
Q_OBJECT
public slots:
void xxx(bool x);
void showpass(bool);
public:
Widget(QWidget *parent = 0);
~Widget();
private:
QPushButton *bt_button; //普通按钮
QToolButton *bt_tool; //工具按钮
QRadioButton *bt_radio; //单选按钮
QRadioButton *bt_radio1;//单选按钮
QCheckBox *bt_check; //复选按钮
QCheckBox *bt_check1; //复选按钮
QCommandLinkButton *bt_cmd;//命令按钮
QLineEdit *le;
QCheckBox *ck;
};
#endif // WIDGET_H
二.布局类
1.水平布局:QVBoxLayout
2.垂直布局:QHBoxLayout
3.网格布局:QGridLayout
三.输出类
1.标签:QLabel
2.文本浏览器:QTextBrowser
3.日历:QCalendarWidget
4.七段数码管:QLCDNumber
5.进度条:QProgressBar
使用示例:widget.cpp
#include "widget.h"
#include <QVBoxLayout>
#include <QMovie>
#include <QTimer>
Widget::Wid