If you want your code to show properly formatted doubles no matter what locale, then you should do this:

Qt Code:
  1. class DoubleDelegate: public QStyledItemDelegate
  2. {
  3. Q_OBJECT
  4. public:
  5.  
  6. DoubleDelegate(QObject* parent=0) : QStyledItemDelegate(parent) { }
  7. virtual ~DoubleDelegate() { }
  8.  
  9. virtual QString displayText(const QVariant &value, const QLocale &locale) const
  10. {
  11. if (value.type() == QVariant::Double) {
  12. return locale.toString( value.toDouble(), 'f', 2 );
  13. }
  14. return QStyledItemDelegate::displayText(value, locale);
  15. }
  16. };
To copy to clipboard, switch view to plain text mode 

Your original code will substitute a comma for a period in all cases, regardless of locale. Maybe that's what you want to do, but an American will certainly be confused seeing a table where the entries are all of the form "123,45".