Qt 常用类(14)—— QCheckBox
来源:互联网 发布:pcb设计软件 编辑:程序博客网 时间:2024/06/16 12:00
QCheckBox 类代表复选钮,它继承了 QAbstractButton 类,因此也有其全部的属性、信号和槽。
构造
QCheckBox 支持以下构造函数:
- QCheckBox(QWidget *parent= 0);
- QCheckBox(const QString &text, QWidget *parent = 0);
其中 text 参数表示要显示的文本。生成的复选钮默认是不排他的。
属性
tristate 属性用于控制复选钮是否为三态的,相关的函数函数如下:
- bool isTristate() const; // 判断是否三态
- void setTristate(bool y = true); // 设置是否为三态的
三态的复选钮不只有打开和关闭两种状态,其状态由 checkState 属性来代表,相关的成员函数如下:
- Qt::CheckState checkState() const; // 获得状态
- void setCheckState(Qt::CheckState state); // 设置是否为三态的
这里 Qt::CheckState 是一个枚举类型,它有以下取值。
1)Qt::Unchecked:未选中。
2)Qt::PartiallyChecked:部分选中。
3)Qt::Checked:选中。
部分选中的状态经常用来表示一个选项树中某个选项的子选项有的选中、有的未选的状态。如果是一个复选钮不是三态的,则也可以用从 QAbstractButton 继承来的 checked 属性操作它的状态。
信号
当复选钮的状态发生变化时,将发射以下信号:
- void stateChanged(int state);
其中参数 state 表示复选钮的新状态
0 0
- Qt 常用类(14)—— QCheckBox
- Qt 常用类(14)—— QCheckBox
- Qt 常用类—— QCheckBox
- Qt 常用类(15)—— QCheckBox
- Qt 常用类(13)—— QPushButton/(14)—— QCheckBox
- Qt常用类QCheckBox
- QT - qss(三)QCheckBox和QRadioButton
- QT常用控件之QVBoxLayout,QRadioButton,QCheckBox,QMenu,QAction
- QCheckBox类
- Qt之QCheckBox
- Qt之QCheckBox
- Qt 之 QCheckBox Class
- 初学Qt:QCheckBox
- Qt学习笔记外观篇(七):QCheckBox
- Qt Style Sheet实践(三):QCheckBox和QRadioButton
- Qt Style Sheet实践(三):QCheckBox和QRadioButton
- QT之qss教程- QCheckBox
- QCheckBox
- 1007
- Qt 常用类(13)—— QPushButton
- MyBatis学习笔记(一)——配置文件中的别名以及mapper中的namespace
- 1008
- 中文分词预处理之N最短路径法小结
- Qt 常用类(14)—— QCheckBox
- 1009
- max()、min()、swap()简单介绍
- 1010
- 1011
- Qt 常用类 (15)—— QRadioButton
- 1012
- ftp连不上的原因
- Android中的IPC方式——使用Bundle和文件共享