QCheckBox
文章目錄
- 1 QCheckBox
- 1.1 QCheckBox簡介
1 QCheckBox
1.1 QCheckBox簡介
QCheckBox 繼承自 QAbstractButton,它提供了一個帶文本標簽的復選框。
QCheckBox(復選框)和 QRadioButton(單選框)都是選項按鈕。這是因為它們都可以在開(選中)或者關(未選中)之間切換。區別是對用戶選擇的限制:單選框定義了“多選一”的選擇,而復選框提供的是“多選多”的選擇。
復選框不同于單選框,它有三種狀態:checked、unchecked 和 PartiallyChecked。
- Qt::Unchecked 0 The item is unchecked.
- Qt::PartiallyChecked 1 The item is partially checked. Items in hierarchical models may be partially checked if some, but not all, of their children are checked.
- Qt::Checked 2 The item is checked.
常用方法和屬性:
//返回選擇的狀態 Qt::CheckState checkState () const //是否處于 PartiallyChecked 狀態 bool isTristate () const //設置選擇的狀態,checked 或 unchecked void setCheckState ( Qt::CheckState state ) //設置為 PartiallyChecked 狀態 void setTristate ( bool y = true ), triple總結
- 上一篇: Qt中的QSpinBox
- 下一篇: QSlider