Displaying a certain number of decimal places for doubles in the table widget should be as simple as using a delegate like:
class Delegate: public QStyledItemDelegate {
Q_OBJECT
public:
Delegate
(QObject *p
= 0): QStyledItemDelegate
(p
) { }
{
return locale.toString(value.toDouble(), 'f', 2);
}
else
return QStyledItemDelegate::displayText(value, locale);
}
};
class Delegate: public QStyledItemDelegate {
Q_OBJECT
public:
Delegate(QObject *p = 0): QStyledItemDelegate(p) { }
QString displayText(const QVariant &value, const QLocale &locale) const
{
if (value.type() == QVariant::Double) {
return locale.toString(value.toDouble(), 'f', 2);
}
else
return QStyledItemDelegate::displayText(value, locale);
}
};
To copy to clipboard, switch view to plain text mode
This is quite distinct from anything to do with what is displayed in an editor for that value.
Bookmarks