From 9995a2910d8a5f0317fe3adeb54f838b99ab31a8 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 3 Dec 2012 08:50:11 -0800 Subject: Add a method that allows registration of files to types There is currently no way in C++ to duplicate the functionality of a qmldir file in mapping QML files to versioned types in a module. This functionality would be useful both in cases where a separate qmldir file would be overkill, and for cases where the type mapping should be generated dynamically. Change-Id: I28d7898122c5556fcd7cf3476795bcf4bb288eab Reviewed-by: Christopher Adams --- src/declarative/qml/qdeclarative.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/declarative/qml/qdeclarative.h') diff --git a/src/declarative/qml/qdeclarative.h b/src/declarative/qml/qdeclarative.h index 4f7dcb2b..68fae370 100644 --- a/src/declarative/qml/qdeclarative.h +++ b/src/declarative/qml/qdeclarative.h @@ -49,6 +49,7 @@ #include #include +#include #include QT_BEGIN_HEADER @@ -390,6 +391,19 @@ int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor, return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type); } +inline int Q_DECLARATIVE_EXPORT qmlRegisterType(const QUrl &url, const char *uri, int versionMajor, int versionMinor, const char *qmlName) +{ + QDeclarativePrivate::RegisterComponent type = { + url, + uri, + qmlName, + versionMajor, + versionMinor + }; + + return QDeclarativePrivate::qmlregister(QDeclarativePrivate::ComponentRegistration, &type); +} + class QDeclarativeContext; class QDeclarativeEngine; Q_DECLARATIVE_EXPORT void qmlExecuteDeferred(QObject *); -- cgit v1.2.3