qt 中对 QDeclarativePropertyMap 的未定义引用
Undefined reference to QDeclarativePropertyMap in qt
我是 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
改用QtQml/QQmlPropertyMap
undefined reference to QDeclarativePropertyMap QObject
是链接器错误,导致您试图混合使用不同版本的 qtquick
我是 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
改用QtQml/QQmlPropertyMap
undefined reference to QDeclarativePropertyMap QObject
是链接器错误,导致您试图混合使用不同版本的 qtquick