Hello,
How does one correctly localize the date time format used in item views?
All I can see is QItemDelegate converting the display role variant to a string, where the QVariant conversion ends up using a hard coded value, Qt::ISODate, for converting the QDateTime. This gives me "YYYY-MM-DDTHH:MM:SS" which is not what I want. Oh, and setting the date time as text is out of question..
What do you think? Have I missed something or is this possibly an overlook by the Trolls?




Reply With Quote

With QItemDelegate::drawDisplay() it's rather straightforward to implement, but as a drawback it ends up doing somewhat excessive QVariant->QString->QDateTime->QString conversions. In addition, I had to use an ugly const_cast to be able to pick the type of the data being rendered as a member variable in paint() so it can later be used in drawDisplay() where the data is unfortunately passed as text.
Bookmarks