1、实现CUIRadioComponent
parent
7f621ffc43
commit
a4491cca36
@ -0,0 +1,56 @@
|
||||
#include "CUIRadioComponent.h"
|
||||
#include "CUIConfig.h"
|
||||
#include "QVBoxLayout"
|
||||
|
||||
#include <QGroupBox>
|
||||
#include <QWidget>
|
||||
#include <QRadioButton>
|
||||
#include <QLabel>
|
||||
|
||||
CUIRadioComponent::CUIRadioComponent(CUIConfig *conf, QVector<CUI *> &subCUI, QWidget *parent) : CUIComponentBaseContainerWidget(parent)
|
||||
{
|
||||
this->conf = conf;
|
||||
iniUI(subCUI);
|
||||
}
|
||||
|
||||
|
||||
void CUIRadioComponent::iniUI(QVector<CUI *> &subCUI)
|
||||
{
|
||||
QString widget_type = this->conf->getPropertyValue("widget");
|
||||
|
||||
QHBoxLayout* mainLayout = new QHBoxLayout;
|
||||
m_layout = this->getLayout(conf);
|
||||
|
||||
if(widget_type == "GroupBox"){
|
||||
iniUI_GroupBox();
|
||||
mainLayout->addWidget(m_GroupBox);
|
||||
}else if(widget_type == "Component"){
|
||||
iniUI_Component();
|
||||
mainLayout->addWidget(m_label);
|
||||
mainLayout->addWidget(m_Component);
|
||||
}
|
||||
|
||||
this->setLayout(mainLayout);
|
||||
}
|
||||
|
||||
void CUIRadioComponent::iniUI_GroupBox()
|
||||
{
|
||||
m_GroupBox = new QGroupBox;
|
||||
m_GroupBox->setTitle(conf->getPropertyValue("name"));
|
||||
m_GroupBox->setLayout(m_layout);
|
||||
for(auto conf:this->conf->getSub()){
|
||||
QRadioButton* radio = new QRadioButton(conf->getPropertyValue("name"));
|
||||
m_layout->addWidget(radio);
|
||||
}
|
||||
}
|
||||
|
||||
void CUIRadioComponent::iniUI_Component()
|
||||
{
|
||||
m_label = new QLabel(conf->getPropertyValue("name"));
|
||||
m_Component = new QWidget;
|
||||
m_Component->setLayout(m_layout);
|
||||
for(auto conf:this->conf->getSub()){
|
||||
QRadioButton* radio = new QRadioButton(conf->getPropertyValue("name"));
|
||||
m_layout->addWidget(radio);
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
/**
|
||||
* 单选框组件
|
||||
*/
|
||||
|
||||
#ifndef CUIRADIOCOMPONENT_H
|
||||
#define CUIRADIOCOMPONENT_H
|
||||
|
||||
#include <QObject>
|
||||
#include <CUIComponentBaseContainerWidget.h>
|
||||
|
||||
class CUIConfig;
|
||||
class CUI;
|
||||
class QLabel;
|
||||
class QHBoxLayout;
|
||||
class QGroupBox;
|
||||
class QWidget;
|
||||
|
||||
class CUIRadioComponent : public CUIComponentBaseContainerWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief CUIRadioComponent构造函数
|
||||
* @param conf配置信息
|
||||
* @param subCUI子组件
|
||||
* @param parent父组件
|
||||
*/
|
||||
explicit CUIRadioComponent(CUIConfig* conf, QVector<CUI*> &subCUI, QWidget *parent = nullptr);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief iniUI渲染ui
|
||||
* @param subCUI子组件
|
||||
*/
|
||||
void iniUI(QVector<CUI*> &subCUI);
|
||||
|
||||
/**
|
||||
* @brief iniUI_GroupBox渲染groupbox类型
|
||||
*/
|
||||
void iniUI_GroupBox();
|
||||
|
||||
/**
|
||||
* @brief iniUI_Component渲染component类型
|
||||
*/
|
||||
void iniUI_Component();
|
||||
|
||||
CUIConfig* conf;
|
||||
QLabel* m_label;
|
||||
QLayout* m_layout;
|
||||
QGroupBox* m_GroupBox;
|
||||
QWidget* m_Component;
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
};
|
||||
|
||||
#endif // CUIRADIOCOMPONENT_H
|
Loading…
Reference in New Issue