MCPcopy Create free account
hub / github.com/QNapi/qnapi / QCheckedListWidget

Class QCheckedListWidget

gui/src/qcheckedlistwidget.h:20–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18#include <QtWidgets>
19
20class QCheckedListWidget : public QListWidget {
21 public:
22 QCheckedListWidget(QWidget* parent = 0) : QListWidget(parent) {
23 setMouseTracking(true);
24 }
25
26 void setItemCheckState(int i, Qt::CheckState state) {
27 QListWidgetItem* it = item(i);
28 if (it) it->setCheckState(state);
29 }
30
31 Qt::CheckState itemCheckState(int i) {
32 QListWidgetItem* it = item(i);
33 return it ? it->checkState() : Qt::Unchecked;
34 }
35
36 void selectAll() {
37 for (int i = 0; i < count(); ++i) {
38 item(i)->setCheckState(Qt::Checked);
39 }
40 }
41
42 void unselectAll() {
43 for (int i = 0; i < count(); ++i) {
44 item(i)->setCheckState(Qt::Unchecked);
45 }
46 }
47
48 void invertSelection() {
49 Qt::CheckState state;
50 for (int i = 0; i < count(); ++i) {
51 state = item(i)->checkState();
52 state = (state == Qt::Checked) ? Qt::Unchecked : Qt::Checked;
53 item(i)->setCheckState(state);
54 }
55 }
56};
57
58#endif // __QCHECKEDLISTWIDGET__H__

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected