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.
AppFlow/CFDStruct/CUIProperty/CUIComponentCheckBox.cpp

37 lines
1013 B
C++

#include "CUIComponentCheckBox.h"
#include <CUIConfig.h>
#include <CUIPropertyWidget.h>
#include <QVBoxLayout>
CUIComponentCheckBox::CUIComponentCheckBox(CUIConfig *conf,
QVector<CUIPropertyWidget *> &subCUI,
QWidget *parent)
: CUIComponentBaseWidget(parent)
{
this->m_conf = conf;
initUI(subCUI);
}
void CUIComponentCheckBox::initUI(QVector<CUIPropertyWidget *> &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);
});
}