You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
#include "CUIComponentCheckBox.h"
|
|
|
|
|
|
|
|
|
|
#include<CUIConfig.h>
|
|
|
|
|
#include<CUI.h>
|
|
|
|
|
#include<QVBoxLayout>
|
|
|
|
|
|
|
|
|
|
CUIComponentCheckBox::CUIComponentCheckBox(CUIConfig* conf, QVector<CUI*> &subCUI, QWidget *parent) : CUIComponentBaseWidget(parent)
|
|
|
|
|
{
|
|
|
|
|
this->m_conf = conf;
|
|
|
|
|
initUI(subCUI);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CUIComponentCheckBox::initUI(QVector<CUI*> &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<int*>(vOrigin);
|
|
|
|
|
if(ptr != nullptr) {
|
|
|
|
|
if(*ptr == 1) {
|
|
|
|
|
m_checkBox->setCheckState(Qt::Checked);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
connect(m_checkBox, QOverload<bool>::of(&QCheckBox::clicked), [ = ](bool sign) {
|
|
|
|
|
this->m_conf->setValue((int)sign);
|
|
|
|
|
});
|
|
|
|
|
}
|