QDataWidgetMapper and formatting date/time
-
There is currently an "order date" column table in a SQLite DB which holds the string "2011-08-21", when that column is mapped (via QDataWidgetMapper) to a QDateEdit, it is not parsing the string into a date correctly. Is there some way to control the formatting in this situation?
Side note, if it matters: In the next 6-month the DB is going to be converted from SQLite to Firebird.
Sam
-
I think the easiest way would be creating a custom QItemDelegate subclass, and override setEditorData and setModelData. In those you can check (qobject_cast) if you're getting/setting data from/to the QDateEdit, and properly convert the string to a QDate or vice-versa.
-
Just for the records:
Unfortunately, SQLite does not provide a native date/time type. It is usually mapped into a string columns (like in your case) or an int or double typed column (usually holding seconds since epoch = 1970-01-01 00:00:00 GMT).PS:
Ah, I see you got that string to date conversion already and just search for the proper way to inject that beast.