What about it does not work? This:
#include <QtGui>
#include <QDebug>
int main(int argc, char *argv[])
{
QString dataricovero
("2012-01-17");
QDate date
= QDate::fromString(dataricovero,
"yyyy-MM-dd");
// OR QDate date= QDate::fromString(dataricovero,Qt::ISODate);
qDebug() << date;
e.setDate(date);
e.show();
return app.exec();
}
#include <QtGui>
#include <QDebug>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QString dataricovero("2012-01-17");
QDate date= QDate::fromString(dataricovero,"yyyy-MM-dd");
// OR QDate date= QDate::fromString(dataricovero,Qt::ISODate);
qDebug() << date;
QDateEdit e;
e.setDate(date);
e.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
outputs 'QDate("Tue Jan 17 2012")' (English locale obviously) and the date edit contains that date.
What is the data type of the Mysql column this value is coming from?
Are you sure that dataricovero is a string in the format you think?
Bookmarks