From 50ecd60c9a3317c92e24b27e37aab83e6716db13 Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Sun, 7 May 2017 23:37:30 +0200 Subject: [PATCH] Inline editing of QDecDouble in AutoTableModel now possible. --- core/autotablemodel.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/autotablemodel.h b/core/autotablemodel.h index f7ee949..1fd9aed 100644 --- a/core/autotablemodel.h +++ b/core/autotablemodel.h @@ -6,6 +6,7 @@ #include #include #include +#include #include "../qdecimal/src/QDecDouble.hh" @@ -264,7 +265,14 @@ public: QSharedPointer entity = m_list.at(index.row()); QObject *rawEntity = (QObject*)entity.data(); - rawEntity->setProperty(rawEntity->metaObject()->property(index.column() + 1).name(), value); + QVariant val = value; + if (rawEntity->property(rawEntity->metaObject()->property(index.column() + 1).name()).canConvert()) + { + QDecDouble dec(val.toDouble()); + val = QVariant::fromValue(dec); + } + + rawEntity->setProperty(rawEntity->metaObject()->property(index.column() + 1).name(), val); } if (role == Qt::CheckStateRole)