diff options
Diffstat (limited to 'example/simple/main.cpp')
-rw-r--r-- | example/simple/main.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/example/simple/main.cpp b/example/simple/main.cpp index 2b19edd..ea9fc86 100644 --- a/example/simple/main.cpp +++ b/example/simple/main.cpp @@ -1,5 +1,6 @@ #include <QtGui/QApplication> #include <QtGui/QWidget> +#include <QtGui/QCheckBox> #include <QtGui/QVBoxLayout> #include "qtsegmentcontrol.h" @@ -9,10 +10,12 @@ class MyWindow : public QWidget public: MyWindow() { controller = new QtSegmentControl(); - controller->setCount(3); + controller->setCount(4); controller->setSegmentText(0, tr("Select One")); controller->setSegmentText(1, tr("Select All")); controller->setSegmentText(2, tr("Select None")); + controller->setSegmentText(3, tr("Permanently Disabled")); + controller->setSegmentEnabled(3, false); controller->setSelectionBehavior(QtSegmentControl::SelectOne); connect(controller, SIGNAL(segmentSelected(int)), this, SLOT(updateBehavior(int))); segmentControl = new QtSegmentControl(); @@ -24,9 +27,14 @@ public: segmentControl->setSegmentText(4, "Maggie"); controller->setSegmentSelected(0, true); + QCheckBox *button = new QCheckBox(tr("Disable Bart")); + button->setChecked(false); + connect(button, SIGNAL(toggled(bool)), SLOT(updateBart(bool))); + QVBoxLayout *vboxlayout = new QVBoxLayout(); vboxlayout->addWidget(controller); vboxlayout->addWidget(segmentControl); + vboxlayout->addWidget(button); setLayout(vboxlayout); } @@ -35,6 +43,10 @@ private slots: segmentControl->setSelectionBehavior(QtSegmentControl::SelectionBehavior(newOne)); } + void updateBart(bool enabled) { + segmentControl->setSegmentEnabled(2, !enabled); + } + private: QtSegmentControl *controller; QtSegmentControl *segmentControl; |