27 #include <QRadioButton>
34 setSizePolicy(QSizePolicy::Policy::Maximum, QSizePolicy::Policy::Maximum);
36 _exclusive = exclusive;
37 _layout =
new QHBoxLayout(
this);
38 _layout->setContentsMargins(0, 0, 0, 0);
39 _layout->setAlignment(Qt::AlignLeft);
40 _label =
new QLabel(label);
41 _layout->addWidget(_label);
42 _layout->addSpacing(15);
45 QAbstractButton* HoriontalButtonGroup::addButton(
bool checked,
const QString& cb_label)
49 QCheckBox* cb =
new QCheckBox(cb_label);
50 cb->setChecked(checked);
51 _layout->addWidget(cb);
55 QRadioButton* cb =
new QRadioButton(cb_label);
56 cb->setChecked(checked);
57 _layout->addWidget(cb);
62 QAbstractButton* HoriontalButtonGroup::widgetButton(
int idx)
64 if (idx >= _boxes.size())
return nullptr;
67 QVector<bool> HoriontalButtonGroup::buttonStates()
const
70 for (QAbstractButton* btn : _boxes)
72 states.push_back(btn->isChecked());
76 void HoriontalButtonGroup::setButtonStates(
const QVector<bool>& states)
78 if (states.size() != noButtons())
84 for (
bool state : states)
86 _boxes[idx]->setChecked(state);
91 QSize HoriontalButtonGroup::sizeHint()
const {
return QSize(50, 5); }