MODIFY:增加double数据的显示格式和精度设置
This commit is contained in:
+9
-3
@@ -96,6 +96,12 @@ void NumKeyDia::setPLineEdit(QLineEdit *newPLineEdit)
|
||||
|
||||
m_isDouble = m_pLineEdit->property("IsDouble").toBool();
|
||||
|
||||
if(m_isDouble)
|
||||
{
|
||||
m_format = m_pLineEdit->property("Format").toInt();
|
||||
m_prec = m_pLineEdit->property("Prec").toInt();
|
||||
}
|
||||
|
||||
if(m_minValue == m_maxValue)
|
||||
{
|
||||
ui->label_min->setText(tr("no limit"));
|
||||
@@ -105,8 +111,8 @@ void NumKeyDia::setPLineEdit(QLineEdit *newPLineEdit)
|
||||
{
|
||||
if(m_isDouble)
|
||||
{
|
||||
ui->label_max->setText(QString::number(m_maxValue, 10, 3));
|
||||
ui->label_min->setText(QString::number(m_minValue, 10, 3));
|
||||
ui->label_max->setText(QString::number(m_maxValue, m_format, m_prec));
|
||||
ui->label_min->setText(QString::number(m_minValue, m_format, m_prec));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -157,7 +163,7 @@ void NumKeyDia::on_btn_ok_clicked()
|
||||
}
|
||||
|
||||
if(m_isDouble)
|
||||
m_pLineEdit->setText(QString::number(_d, 10, 3));
|
||||
m_pLineEdit->setText(QString::number(_d, m_format, m_prec));
|
||||
else
|
||||
m_pLineEdit->setText(QString::number(_d, 10, 0));
|
||||
}
|
||||
|
||||
@@ -56,6 +56,8 @@ private:
|
||||
double m_maxValue = 0.000;
|
||||
bool m_isNum = false;
|
||||
bool m_isDouble = false;
|
||||
char m_format = 'f';
|
||||
int m_prec = 3;
|
||||
};
|
||||
|
||||
#endif // NUMKEYDIA_H
|
||||
|
||||
Reference in New Issue
Block a user