修改外部同步器的编辑逻辑、添加‘另存为’ 按钮
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
|
||||
#ifndef _CUSTOM_DOUBLE_SPIN_BOX_H_
|
||||
#define _CUSTOM_DOUBLE_SPIN_BOX_H_
|
||||
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QString>
|
||||
|
||||
class CustomDoubleSpinBox : public QDoubleSpinBox {
|
||||
public:
|
||||
explicit CustomDoubleSpinBox(QWidget *parent = nullptr) : QDoubleSpinBox(parent) {
|
||||
// 设置一个较大的最大位数,让用户有足够的输入精度
|
||||
setDecimals(10);
|
||||
}
|
||||
|
||||
protected:
|
||||
// 重写此方法,自定义数值如何显示在输入框中
|
||||
QString textFromValue(double value) const override {
|
||||
// 使用 'g' 格式可以自动去掉末尾不必要的零
|
||||
// 或者使用 QString::number 配合手动处理
|
||||
return QString::number(value, 'g', decimals());
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _CUSTOM_DOUBLE_SPIN_BOX_H_
|
||||
Reference in New Issue
Block a user