Hi all,
as you can see in the two images, Date is formatted with differences on Mac and on Win
here is the code:
#include "CustomModel.h"
#include <QtGui>
}
if (value.isValid() && role == Qt::DisplayRole) {
if (index.column() == 1)
return value.toString();
else if (index.column() == 2)
return value.toString();
else if (index.column() == 3)
return QDateTime::fromString(value.
toString(),
"dd.MM.yyyy hh:mm:ss");
}
return value;
}
#include "CustomModel.h"
#include <QtGui>
CustomModel::CustomModel(QObject *parent): QSqlQueryModel(parent) {
}
QVariant CustomModel::data(const QModelIndex &index, int role) const {
QVariant value = QSqlQueryModel::data(index, role);
if (value.isValid() && role == Qt::DisplayRole) {
if (index.column() == 1)
return value.toString();
else if (index.column() == 2)
return value.toString();
else if (index.column() == 3)
return QDateTime::fromString(value.toString(),"dd.MM.yyyy hh:mm:ss");
}
return value;
}
To copy to clipboard, switch view to plain text mode
Mac:
http://img253.imageshack.us/my.php?i...agine18uz4.png
Win:
http://img187.imageshack.us/my.php?image=datako9.jpg
Does anybody know why?
Thanks, Bye
Bookmarks