我是Qt的新手。
Qml在将QDeclarativePropertyMap从c ++传递给Qml时面临问题。
这是我的代码:
的main.cpp
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QtDeclarative/qdeclarativepropertymap.h>
#include <QVariant>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QQmlApplicationEngine engine;
///giving error in below line
QDeclarativePropertyMap *m_propertymap = new QDeclarativePropertyMap();
m_propertymap->insert("time" ,QVariant(QString("yet to do")));
m_propertymap->insert("area" ,QVariant(QString("india")));
engine.rootContext()->setContextProperty("M_propertymap", m_propertymap);
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
}
错误:
undefined reference to QDeclarativePropertyMap QObject
答案 0 :(得分:0)
使用QtQml/QQmlPropertyMap
代替
对QDeclarativePropertyMap QObject的未定义引用
是链接器错误,导致您尝试混合不同版本的qtquick