diff options
Diffstat (limited to 'src/qml/qml/qqml.h')
-rw-r--r-- | src/qml/qml/qqml.h | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/qml/qml/qqml.h b/src/qml/qml/qqml.h index 597c59eeff..7e6e0d1d36 100644 --- a/src/qml/qml/qqml.h +++ b/src/qml/qml/qqml.h @@ -49,8 +49,7 @@ #include <QtCore/qbytearray.h> #include <QtCore/qmetaobject.h> - -QT_BEGIN_HEADER +#include <QtCore/qdebug.h> #define QML_VERSION 0x020000 #define QML_VERSION_STR "2.0" @@ -465,11 +464,29 @@ inline int qmlRegisterSingletonType(const char *uri, int versionMajor, int versi return QQmlPrivate::qmlregister(QQmlPrivate::SingletonRegistration, &api); } + +inline int qmlRegisterType(const QUrl &url, const char *uri, int versionMajor, int versionMinor, const char *qmlName) +{ + if (url.isRelative()) { + // User input check must go here, because QQmlPrivate::qmlregister is also used internally for composite types + qWarning() << "qmlRegisterType requires absolute URLs."; + return 0; + } + + QQmlPrivate::RegisterCompositeType type = { + url, + uri, + versionMajor, + versionMinor, + qmlName + }; + + return QQmlPrivate::qmlregister(QQmlPrivate::CompositeRegistration, &type); +} + QT_END_NAMESPACE QML_DECLARE_TYPE(QObject) Q_DECLARE_METATYPE(QVariant) -QT_END_HEADER - #endif // QQML_H |