#include "CUIComponentCheckBox.h" #include #include #include CUIComponentCheckBox::CUIComponentCheckBox(CUIConfig* conf, QVector &subCUI, QWidget *parent) : CUIComponentBaseWidget(parent) { this->m_conf = conf; initUI(subCUI); } void CUIComponentCheckBox::initUI(QVector &subCUI) { m_checkBox = new QCheckBox(); m_checkBox->setText(m_conf->getPropertyValue("name")); QVBoxLayout* layout = new QVBoxLayout; layout->addWidget(m_checkBox); this->setLayout(layout); // 设置值和响应 QVariant vOrigin = m_conf->getPropertyOriginValue("value_origin"); int *ptr = qvariant_cast(vOrigin); if(ptr != nullptr) { if(*ptr == 1) { m_checkBox->setCheckState(Qt::Checked); } } connect(m_checkBox, QOverload::of(&QCheckBox::clicked), [ = ](bool sign) { this->m_conf->setValue((int)sign); }); }