我有以下内容QObject
:
#ifndef UETYPES
#define UETYPES
#include <QHash>
#include <QByteArray>
#include <QMultiMap>
#include <QString>
#include <QObject>
#include "../database/ueuserrecord.h"
#include "../database/ueorderrecord.h"
class UeTypes : public QObject
{
Q_OBJECT
public:
typedef QHash<int, QByteArray> UeTypeRoles;
/*
* QString first parameter userId
* QString second parameter placeId
*/
typedef QMultiMap<QString, QString> UeTypeLoggedUsers;
};
#endif // UETYPES
我正在尝试通过 main.cpp 公开/导出到typedef QMultiMap<QString, QString> UeTypeLoggedUsers
QML :qmlRegisterType
#include <QtQml>
#include <QApplication>
#include <QQmlApplicationEngine>
#include "core/uetypes.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QQmlApplicationEngine engine;
qmlRegisterType<UeTypes::UeTypeLoggedUsers>("si.test",
1,
0,
"UeTypeLoggedUsers");
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
}
但是,当我尝试编译此代码时,出现以下错误:
错误:“staticMetaObject”不是“QMultiMap”的成员
为什么我会收到这个错误,我该如何摆脱它?