From 914292f2999e4af2acd0a26e76b88adef7d42a8f Mon Sep 17 00:00:00 2001 From: mgrojo Date: Fri, 15 Nov 2019 21:21:06 +0100 Subject: [PATCH] Use the column type affinity for the default text alignment In this way the entire column has the same alignment and gives a hint of the column datatype. Note that if the DB has data incoherent with the affinity, it will not be reflected in the text alignment. See issue #2032 --- src/sqlitetablemodel.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sqlitetablemodel.cpp b/src/sqlitetablemodel.cpp index d0980e4d..e18f0105 100644 --- a/src/sqlitetablemodel.cpp +++ b/src/sqlitetablemodel.cpp @@ -409,8 +409,7 @@ QVariant SqliteTableModel::data(const QModelIndex &index, int role) const QVariant condFormat = getMatchingCondFormat(row, column, data, role); if (condFormat.isValid()) return condFormat; - bool isNumber; - data.toDouble(&isNumber); + bool isNumber = m_vDataTypes.at(column) == SQLITE_INTEGER || m_vDataTypes.at(column) == SQLITE_FLOAT; return static_cast((isNumber ? Qt::AlignRight : Qt::AlignLeft) | Qt::AlignVCenter); } else if(role == Qt::DecorationRole) { if(!row_available)