Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
5.2.0
-
None
-
7f50eca469a24809d6d5812ee94b447966ff81f9
Description
#include <QCoreApplication> #include <QDebug> #include <QLocale> #include <QQmlComponent> #include <QQmlEngine> class CalendarModel : public QObject { Q_OBJECT Q_PROPERTY(QLocale locale READ locale WRITE setLocale) public: CalendarModel() { } CalendarModel(const CalendarModel &rhs) { mLocale = rhs.mLocale; } QLocale locale() const { return mLocale; } void setLocale(const QLocale &locale) { mLocale = locale; } private: QLocale mLocale; }; Q_DECLARE_METATYPE(CalendarModel) int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QQmlEngine engine; QQmlComponent component(&engine); qmlRegisterType<CalendarModel>("Test", 1, 0, "CalendarModel"); component.setData("import QtQml 2.2\n" "import Test 1.0\n" "QtObject {" //" property Locale theLocale: Qt.locale()\n" " property var theLocale: Qt.locale()\n" " property CalendarModel model: CalendarModel {" " locale: theLocale" "} }", QUrl()); if (component.isError()) { qWarning() << component.errorString(); return 0; } else { while (!component.isReady()) { QCoreApplication::processEvents(); } QObject *item = qobject_cast<QObject*>(component.create()); //qDebug() << item->property("locale").value<Calendar>().locale().name(); } return a.exec(); } #include "main.moc"
Using var as the property type gives me this error:
<Unknown File>: Unable to assign QVariantMap to QLocale
Using Locale as the property type gives me the this error:
:3 Locale cannot be instantiated. Use Qt.locale()