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.
nmWTAI-Platform/Include/nmNum/nmGUI/nmGUIComponentBase.h

69 lines
1.5 KiB
C++

#ifndef NMGUICOMPONENTBASE_H
#define NMGUICOMPONENTBASE_H
#include <QWidget>
#include <QVariant>
#include "nmGUIDefine.h"
#include "nmGUI_global.h"
class QHBoxLayout;
class QLabel;
class QLineEdit;
class QComboBox;
class nmDataAttribute;
class NM_GUI_EXPORT nmGUIComponentBase : public QWidget {
Q_OBJECT
public:
explicit nmGUIComponentBase(nmDataAttribute* pOriginValue,bool enable = true, QWidget *parent = nullptr);
bool updateValueToOrigin();
bool updateValueFromOrigin();
void initInitValue();
virtual void init();
void initUI();
void initLayout();
void initComponents();
// 设置是否实时更新value到数据源
void setIsRealTimeUpdateValue(bool isUpdate);
void setOriginValue(nmDataAttribute* pOriginValue);
protected:
// 布局
QHBoxLayout* m_pLayout;
// 左边的名称Lable
QLabel* m_pNameLabel;
// 中间的设置值组件
QWidget* m_pValueEdit;
// 右侧的单位Lable
QComboBox* m_pUnitComboBox;
nmDataAttribute* m_pOriginValue;
bool m_isEnable;
NM_GUI_Component_Type m_eUIType;
double m_baseValue;
QString m_baseUnit;
QString m_currentUnit;
bool m_valueEditedByUser;
QString m_lastValidValue; // 保存上一个有效值
// 是否实时更新值
bool m_bIsUpdateValue;
private slots:
//void on_valueChanged(QString);
void onUnitChanged(int index);
void onValueEdited(const QString &);
// 编辑完成
void onValueEditFinish();
};
#endif // NMGUICOMPONENTBASE_H