Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qqml.h
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQML_H
5#define QQML_H
6
7#include <QtQml/qqmlprivate.h>
8#include <QtQml/qjsvalue.h>
9#include <QtQml/qqmlregistration.h>
10
11#include <QtCore/qbytearray.h>
12#include <QtCore/qmetaobject.h>
13#include <QtCore/qmetacontainer.h>
14#include <QtCore/qversionnumber.h>
15
16#define QML_VERSION 0x020000
17#define QML_VERSION_STR "2.0"
18
19#define QML_DECLARE_TYPE(TYPE) \
20 Q_DECLARE_METATYPE(TYPE*) \
21 Q_DECLARE_METATYPE(QQmlListProperty<TYPE>)
22
23#define QML_DECLARE_TYPE_HASMETATYPE(TYPE) \
24 Q_DECLARE_METATYPE(QQmlListProperty<TYPE>)
25
26#define QML_DECLARE_INTERFACE(INTERFACE) \
27 QML_DECLARE_TYPE(INTERFACE)
28
29#define QML_DECLARE_INTERFACE_HASMETATYPE(INTERFACE) \
30 QML_DECLARE_TYPE_HASMETATYPE(INTERFACE)
31
32enum { /* TYPEINFO flags */
34};
35
36#define QML_DECLARE_TYPEINFO(TYPE, FLAGS) \
37QT_BEGIN_NAMESPACE \
38template <> \
39class QQmlTypeInfo<TYPE > \
40{ \
41public: \
42 enum { \
43 hasAttachedProperties = (((FLAGS) & QML_HAS_ATTACHED_PROPERTIES) == QML_HAS_ATTACHED_PROPERTIES) \
44 }; \
45}; \
46QT_END_NAMESPACE
47
49
50void Q_QML_EXPORT qmlClearTypeRegistrations();
51
52template<class T>
54
55template<typename T>
56int qmlRegisterAnonymousType(const char *uri, int versionMajor)
57{
62 0,
63 nullptr, nullptr,
64 QString(),
66
67 uri, QTypeRevision::fromVersion(versionMajor, 0), nullptr,
69
70 QQmlPrivate::attachedPropertiesFunc<T>(),
71 QQmlPrivate::attachedPropertiesMetaObject<T>(),
72
76
77 nullptr, nullptr,
78
79 nullptr,
83 };
84
86}
87
89template<typename T, int metaObjectRevisionMinor>
90int qmlRegisterAnonymousType(const char *uri, int versionMajor)
91{
96 0,
97 nullptr,
98 nullptr,
99 QString(),
101
102 uri,
103 QTypeRevision::fromVersion(versionMajor, 0),
104 nullptr,
106
107 QQmlPrivate::attachedPropertiesFunc<T>(),
108 QQmlPrivate::attachedPropertiesMetaObject<T>(),
109
113
114 nullptr,
115 nullptr,
116
117 nullptr,
118 QTypeRevision::fromMinorVersion(metaObjectRevisionMinor),
121 };
122
124}
125
127template<typename T>
128void qmlRegisterAnonymousTypesAndRevisions(const char *uri, int versionMajor)
129{
130 // Anonymous types are not creatable, no need to warn about missing acceptable constructors.
131 QQmlPrivate::qmlRegisterTypeAndRevisions<T, void>(
132 uri, versionMajor, QQmlPrivate::StaticMetaObject<T>::staticMetaObject(), nullptr,
133 nullptr, true);
134}
135
137{
139 QML_NAMED_ELEMENT(TypeNotAvailable)
141 QML_UNCREATABLE("Type not available.")
142};
143
144int Q_QML_EXPORT qmlRegisterTypeNotAvailable(const char *uri, int versionMajor, int versionMinor,
145 const char *qmlName, const QString &message);
146
147template<typename T>
148int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& reason)
149{
154 0,
155 nullptr,
156 nullptr,
157 reason,
159
160 uri, QTypeRevision::fromVersion(versionMajor, versionMinor), qmlName,
162
163 QQmlPrivate::attachedPropertiesFunc<T>(),
164 QQmlPrivate::attachedPropertiesMetaObject<T>(),
165
169
170 nullptr, nullptr,
171
172 nullptr,
176 };
177
179}
180
181template<typename T, int metaObjectRevision>
182int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& reason)
183{
188 0,
189 nullptr,
190 nullptr,
191 reason,
193
194 uri, QTypeRevision::fromVersion(versionMajor, versionMinor), qmlName,
196
197 QQmlPrivate::attachedPropertiesFunc<T>(),
198 QQmlPrivate::attachedPropertiesMetaObject<T>(),
199
203
204 nullptr, nullptr,
205
206 nullptr,
207 QTypeRevision::fromMinorVersion(metaObjectRevision),
210 };
211
213}
214
215template<typename T, typename E>
216int qmlRegisterExtendedUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& reason)
217{
218 QQmlAttachedPropertiesFunc attached = QQmlPrivate::attachedPropertiesFunc<E>();
219 const QMetaObject * attachedMetaObject = QQmlPrivate::attachedPropertiesMetaObject<E>();
220 if (!attached) {
221 attached = QQmlPrivate::attachedPropertiesFunc<T>();
222 attachedMetaObject = QQmlPrivate::attachedPropertiesMetaObject<T>();
223 }
224
229 0,
230 nullptr,
231 nullptr,
232 reason,
234
235 uri, QTypeRevision::fromVersion(versionMajor, versionMinor), qmlName,
237
238 attached,
239 attachedMetaObject,
240
244
246
247 nullptr,
251 };
252
254}
255
256template<typename T, typename E, int metaObjectRevision>
257int qmlRegisterExtendedUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& reason)
258{
259 QQmlAttachedPropertiesFunc attached = QQmlPrivate::attachedPropertiesFunc<E>();
260 const QMetaObject * attachedMetaObject = QQmlPrivate::attachedPropertiesMetaObject<E>();
261 if (!attached) {
262 attached = QQmlPrivate::attachedPropertiesFunc<T>();
263 attachedMetaObject = QQmlPrivate::attachedPropertiesMetaObject<T>();
264 }
265
270 0,
271 nullptr,
272 nullptr,
273 reason,
275
276 uri, QTypeRevision::fromVersion(versionMajor, versionMinor), qmlName,
278
279 attached,
280 attachedMetaObject,
281
285
287
288 nullptr,
289 QTypeRevision::fromMinorVersion(metaObjectRevision),
292 };
293
295}
296
297Q_QML_EXPORT int qmlRegisterUncreatableMetaObject(const QMetaObject &staticMetaObject, const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& reason);
298
299template<typename T>
300int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
301{
302 static_assert(!std::is_abstract_v<T>,
303 "It is not possible to register an abstract type with qmlRegisterType. "
304 "Maybe you wanted qmlRegisterUncreatableType or qmlRegisterInterface?");
305
311 QString(),
313
314 uri, QTypeRevision::fromVersion(versionMajor, versionMinor), qmlName,
316
317 QQmlPrivate::attachedPropertiesFunc<T>(),
318 QQmlPrivate::attachedPropertiesMetaObject<T>(),
319
323
324 nullptr, nullptr,
325
326 nullptr,
330 };
331
333}
334
335template<typename T, int metaObjectRevision>
336int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
337{
338 static_assert(!std::is_abstract_v<T>,
339 "It is not possible to register an abstract type with qmlRegisterType. "
340 "Maybe you wanted qmlRegisterUncreatableType or qmlRegisterInterface?");
341
347 QString(),
349
350 uri, QTypeRevision::fromVersion(versionMajor, versionMinor), qmlName,
352
353 QQmlPrivate::attachedPropertiesFunc<T>(),
354 QQmlPrivate::attachedPropertiesMetaObject<T>(),
355
359
360 nullptr, nullptr,
361
362 nullptr,
363 QTypeRevision::fromMinorVersion(metaObjectRevision),
366 };
367
369}
370
371template<typename T, int metaObjectRevision>
372int qmlRegisterRevision(const char *uri, int versionMajor, int versionMinor)
373{
379 QString(),
381
382 uri, QTypeRevision::fromVersion(versionMajor, versionMinor), nullptr,
384
385 QQmlPrivate::attachedPropertiesFunc<T>(),
386 QQmlPrivate::attachedPropertiesMetaObject<T>(),
387
391
392 nullptr, nullptr,
393
394 nullptr,
395 QTypeRevision::fromMinorVersion(metaObjectRevision),
398 };
399
401}
402
403template<typename T, typename E>
404int qmlRegisterExtendedType(const char *uri, int versionMajor)
405{
406 static_assert(!std::is_abstract_v<T>,
407 "It is not possible to register an extension to an abstract type with qmlRegisterExtendedType.");
408
409 static_assert(!std::is_abstract_v<E>,
410 "It is not possible to register an abstract type with qmlRegisterExtendedType. "
411 "Maybe you wanted qmlRegisterExtendedUncreatableType?");
412
417 0,
418 nullptr,
419 nullptr,
420 QString(),
422
423 uri, QTypeRevision::fromVersion(versionMajor, 0), nullptr,
425
426 QQmlPrivate::attachedPropertiesFunc<T>(),
427 QQmlPrivate::attachedPropertiesMetaObject<T>(),
428
432
434
435 nullptr,
439 };
440
442}
443
444template<typename T, typename E>
445int qmlRegisterExtendedType(const char *uri, int versionMajor, int versionMinor,
446 const char *qmlName)
447{
448 static_assert(!std::is_abstract_v<T>,
449 "It is not possible to register an extension to an abstract type with qmlRegisterExtendedType.");
450
451 static_assert(!std::is_abstract_v<E>,
452 "It is not possible to register an abstract type with qmlRegisterExtendedType. "
453 "Maybe you wanted qmlRegisterExtendedUncreatableType?");
454
455 QQmlAttachedPropertiesFunc attached = QQmlPrivate::attachedPropertiesFunc<E>();
456 const QMetaObject * attachedMetaObject = QQmlPrivate::attachedPropertiesMetaObject<E>();
457 if (!attached) {
458 attached = QQmlPrivate::attachedPropertiesFunc<T>();
459 attachedMetaObject = QQmlPrivate::attachedPropertiesMetaObject<T>();
460 }
461
467 QString(),
469
470 uri, QTypeRevision::fromVersion(versionMajor, versionMinor), qmlName,
472
473 attached,
474 attachedMetaObject,
475
479
481
482 nullptr,
486 };
487
489}
490
491template<typename T>
492int qmlRegisterInterface(const char *uri, int versionMajor)
493{
494 QQmlPrivate::RegisterInterface qmlInterface = {
495 0,
496 // An interface is not a QObject itself but is typically casted to one.
497 // Therefore, we still want the pointer.
498 QMetaType::fromType<T *>(),
499 QMetaType::fromType<QQmlListProperty<T> >(),
500 qobject_interface_iid<T *>(),
501
502 uri,
503 QTypeRevision::fromVersion(versionMajor, 0)
504 };
505
507}
508
509template<typename T>
510int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor,
511 const char *qmlName, QQmlCustomParser *parser)
512{
513 static_assert(!std::is_abstract_v<T>,
514 "It is not possible to register an abstract type with qmlRegisterCustomType. "
515 "Maybe you wanted qmlRegisterUncreatableType or qmlRegisterInterface?");
516
522 QString(),
524
525 uri, QTypeRevision::fromVersion(versionMajor, versionMinor), qmlName,
527
528 QQmlPrivate::attachedPropertiesFunc<T>(),
529 QQmlPrivate::attachedPropertiesMetaObject<T>(),
530
534
535 nullptr, nullptr,
536
537 parser,
541 };
542
544}
545
546template<typename T, int metaObjectRevision>
547int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor,
548 const char *qmlName, QQmlCustomParser *parser)
549{
550 static_assert(!std::is_abstract_v<T>,
551 "It is not possible to register an abstract type with qmlRegisterCustomType. "
552 "Maybe you wanted qmlRegisterUncreatableType or qmlRegisterInterface?");
553
559 QString(),
561
562 uri, QTypeRevision::fromVersion(versionMajor, versionMinor), qmlName,
564
565 QQmlPrivate::attachedPropertiesFunc<T>(),
566 QQmlPrivate::attachedPropertiesMetaObject<T>(),
567
571
572 nullptr, nullptr,
573
574 parser,
575 QTypeRevision::fromMinorVersion(metaObjectRevision),
578 };
579
581}
582
583template<typename T, typename E>
584int qmlRegisterCustomExtendedType(const char *uri, int versionMajor, int versionMinor,
585 const char *qmlName, QQmlCustomParser *parser)
586{
587 static_assert(!std::is_abstract_v<T>,
588 "It is not possible to register an extension to an abstract type with qmlRegisterCustomExtendedType.");
589
590 static_assert(!std::is_abstract_v<E>,
591 "It is not possible to register an abstract type with qmlRegisterCustomExtendedType.");
592
593 QQmlAttachedPropertiesFunc attached = QQmlPrivate::attachedPropertiesFunc<E>();
594 const QMetaObject * attachedMetaObject = QQmlPrivate::attachedPropertiesMetaObject<E>();
595 if (!attached) {
596 attached = QQmlPrivate::attachedPropertiesFunc<T>();
597 attachedMetaObject = QQmlPrivate::attachedPropertiesMetaObject<T>();
598 }
599
605 QString(),
607
608 uri, QTypeRevision::fromVersion(versionMajor, versionMinor), qmlName,
610
611 attached,
612 attachedMetaObject,
613
617
619
620 parser,
624 };
625
627}
628
629class QQmlContext;
630class QQmlEngine;
631class QJSValue;
632class QJSEngine;
633
634Q_QML_EXPORT void qmlExecuteDeferred(QObject *);
635Q_QML_EXPORT QQmlContext *qmlContext(const QObject *);
636Q_QML_EXPORT QQmlEngine *qmlEngine(const QObject *);
638 const QMetaObject *);
640 bool create = true);
641Q_QML_EXPORT QObject *qmlExtendedObject(QObject *);
642
643//The C++ version of protected namespaces in qmldir
644Q_QML_EXPORT bool qmlProtectModule(const char* uri, int majVersion);
645Q_QML_EXPORT void qmlRegisterModule(const char *uri, int versionMajor, int versionMinor);
646
652
653Q_QML_EXPORT void qmlRegisterModuleImport(const char *uri, int moduleMajor,
654 const char *import,
655 int importMajor = QQmlModuleImportLatest,
656 int importMinor = QQmlModuleImportLatest);
657Q_QML_EXPORT void qmlUnregisterModuleImport(const char *uri, int moduleMajor,
658 const char *import,
659 int importMajor = QQmlModuleImportLatest,
660 int importMinor = QQmlModuleImportLatest);
661
662template<typename T>
664{
665 // We don't need a concrete object to resolve the function. As T is a C++ type, it and all its
666 // super types should be registered as CppType (or not at all). We only need the object and its
667 // QML engine to resolve composite types. Therefore, the function is actually a static property
668 // of the C++ type system and we can cache it here for improved performance on further lookups.
669 static const auto func = qmlAttachedPropertiesFunction(nullptr, &T::staticMetaObject);
670 return qmlAttachedPropertiesObject(const_cast<QObject *>(obj), func, create);
671}
672
673inline int qmlRegisterSingletonType(const char *uri, int versionMajor, int versionMinor, const char *typeName,
674 QJSValue (*callback)(QQmlEngine *, QJSEngine *))
675{
677 0,
678
679 uri, QTypeRevision::fromVersion(versionMajor, versionMinor), typeName,
680
681 callback,
682 nullptr, nullptr, QMetaType(),
683 nullptr, nullptr,
685 };
686
688}
689
690template <typename T>
692 const char *uri, int versionMajor, int versionMinor, const char *typeName,
693 QObject *(*callback)(QQmlEngine *, QJSEngine *))
694{
696 0,
697 uri,
698 QTypeRevision::fromVersion(versionMajor, versionMinor),
699 typeName,
700 nullptr,
701 callback,
704 nullptr, nullptr,
706 };
707
709}
710
711#ifdef Q_QDOC
712template <typename T>
713int qmlRegisterSingletonType(const char *uri, int versionMajor, int versionMinor, const char *typeName, std::function<QObject*(QQmlEngine *, QJSEngine *)> callback)
714#else
715template <typename T, typename F, typename std::enable_if<std::is_convertible<F, std::function<QObject *(QQmlEngine *, QJSEngine *)>>::value
716 && !std::is_convertible<F, QObject *(*)(QQmlEngine *, QJSEngine *)>::value, void>::type* = nullptr>
717inline int qmlRegisterSingletonType(const char *uri, int versionMajor, int versionMinor, const char *typeName,
718 F&& callback)
719#endif
720{
722 0,
723 uri,
724 QTypeRevision::fromVersion(versionMajor, versionMinor),
725 typeName,
726 nullptr,
727 callback,
730 nullptr, nullptr,
732 };
733
735}
736
737#ifdef Q_QDOC
738int qmlRegisterSingletonInstance(const char *uri, int versionMajor, int versionMinor, const char *typeName, QObject *cppObject)
739#else
740template<typename T>
741inline auto qmlRegisterSingletonInstance(const char *uri, int versionMajor, int versionMinor,
742 const char *typeName, T *cppObject) -> typename std::enable_if<std::is_base_of<QObject, T>::value, int>::type
743#endif
744{
745 QQmlPrivate::SingletonInstanceFunctor registrationFunctor;
746 registrationFunctor.m_object = cppObject;
747 return qmlRegisterSingletonType<T>(uri, versionMajor, versionMinor, typeName, registrationFunctor);
748}
749
750inline int qmlRegisterSingletonType(const QUrl &url, const char *uri, int versionMajor, int versionMinor, const char *qmlName)
751{
752 if (url.isRelative()) {
753 // User input check must go here, because QQmlPrivate::qmlregister is also used internally for composite types
754 qWarning("qmlRegisterSingletonType requires absolute URLs.");
755 return 0;
756 }
757
759 0,
760 url,
761 uri,
762 QTypeRevision::fromVersion(versionMajor, versionMinor),
763 qmlName
764 };
765
767}
768
769inline int qmlRegisterType(const QUrl &url, const char *uri, int versionMajor, int versionMinor, const char *qmlName)
770{
771 if (url.isRelative()) {
772 // User input check must go here, because QQmlPrivate::qmlregister is also used internally for composite types
773 qWarning("qmlRegisterType requires absolute URLs.");
774 return 0;
775 }
776
778 0,
779 url,
780 uri,
781 QTypeRevision::fromVersion(versionMajor, versionMinor),
782 qmlName
783 };
784
786}
787
788template<typename Container>
789inline int qmlRegisterAnonymousSequentialContainer(const char *uri, int versionMajor)
790{
791 static_assert(!std::is_abstract_v<Container>,
792 "It is not possible to register an abstract container with qmlRegisterAnonymousSequentialContainer.");
793
795 0,
796 uri,
798 nullptr,
799 QMetaType::fromType<Container>(),
800 QMetaSequence::fromContainer<Container>(),
802 };
803
805}
806
807template<class T, class Resolved, class Extended, bool Singleton, bool Interface, bool Sequence, bool Uncreatable>
809
810template<class T, class Resolved, class Extended>
811struct QmlTypeAndRevisionsRegistration<T, Resolved, Extended, false, false, false, false> {
812 static void registerTypeAndRevisions(const char *uri, int versionMajor, QList<int> *qmlTypeIds,
813 const QMetaObject *extension)
814 {
815#if QT_DEPRECATED_SINCE(6, 4)
816 // ### Qt7: Remove the warnings, and leave only the static asserts below.
819 QMetaType::fromType<Resolved>());
820 }
821
822 if constexpr (!std::is_base_of_v<QObject, Resolved>
825 QMetaType::fromType<Resolved>());
826 }
827#else
829 "This type is neither a default constructible QObject, nor a default- "
830 "and copy-constructible Q_GADGET, nor marked as uncreatable.\n"
831 "You should not use it as a QML type.");
832 static_assert(std::is_base_of_v<QObject, Resolved>
834#endif
835 QQmlPrivate::qmlRegisterTypeAndRevisions<Resolved, Extended>(
837 qmlTypeIds, extension);
838 }
839};
840
841template<class T, class Resolved, class Extended>
842struct QmlTypeAndRevisionsRegistration<T, Resolved, Extended, false, false, false, true> {
843 static void registerTypeAndRevisions(const char *uri, int versionMajor, QList<int> *qmlTypeIds,
844 const QMetaObject *extension)
845 {
846#if QT_DEPRECATED_SINCE(6, 4)
847 // ### Qt7: Remove the warning, and leave only the static assert below.
848 if constexpr (!std::is_base_of_v<QObject, Resolved>
851 QMetaType::fromType<Resolved>());
852 }
853#else
854 static_assert(std::is_base_of_v<QObject, Resolved>
856#endif
857 QQmlPrivate::qmlRegisterTypeAndRevisions<Resolved, Extended>(
859 qmlTypeIds, extension);
860 }
861};
862
863template<class T, class Resolved>
864struct QmlTypeAndRevisionsRegistration<T, Resolved, void, false, false, true, true> {
865 static void registerTypeAndRevisions(const char *uri, int versionMajor, QList<int> *qmlTypeIds,
866 const QMetaObject *)
867 {
868 // Sequences have to be anonymous for now, which implies uncreatable.
869 QQmlPrivate::qmlRegisterSequenceAndRevisions<Resolved>(
871 qmlTypeIds);
872 }
873};
874
875template<class T, class Resolved, class Extended>
876struct QmlTypeAndRevisionsRegistration<T, Resolved, Extended, true, false, false, false> {
877 static void registerTypeAndRevisions(const char *uri, int versionMajor, QList<int> *qmlTypeIds,
878 const QMetaObject *extension)
879 {
880#if QT_DEPRECATED_SINCE(6, 4)
881 // ### Qt7: Remove the warning, and leave only the static assert below.
882 if constexpr (QQmlPrivate::singletonConstructionMode<Resolved, T>()
885 QMetaType::fromType<Resolved>());
886 }
887#else
888 static_assert(QQmlPrivate::singletonConstructionMode<Resolved, T>()
890 "A singleton needs either a default constructor or, when adding a default "
891 "constructor is infeasible, a public static "
892 "create(QQmlEngine *, QJSEngine *) method");
893#endif
894
895 QQmlPrivate::qmlRegisterSingletonAndRevisions<Resolved, Extended, T>(
897 qmlTypeIds, extension);
898 }
899};
900
901template<class T, class Resolved, class Extended>
902struct QmlTypeAndRevisionsRegistration<T, Resolved, Extended, true, false, false, true> {
903 static void registerTypeAndRevisions(const char *uri, int versionMajor, QList<int> *qmlTypeIds,
904 const QMetaObject *extension)
905 {
906 // An uncreatable singleton makes little sense? OK, you can still use the enums.
907 QQmlPrivate::qmlRegisterSingletonAndRevisions<Resolved, Extended, T>(
909 qmlTypeIds, extension);
910 }
911};
912
913template<class T, class Resolved>
914struct QmlTypeAndRevisionsRegistration<T, Resolved, void, false, true, false, false> {
915 static void registerTypeAndRevisions(const char *uri, int versionMajor, QList<int> *qmlTypeIds,
916 const QMetaObject *)
917 {
918 const int id = qmlRegisterInterface<Resolved>(uri, versionMajor);
919 if (qmlTypeIds)
920 qmlTypeIds->append(id);
921 }
922};
923
924template<typename... T>
925void qmlRegisterTypesAndRevisions(const char *uri, int versionMajor, QList<int> *qmlTypeIds)
926{
934 ::registerTypeAndRevisions(uri, versionMajor, qmlTypeIds,
936}
937
939 const char *uri, int versionMajor,
940 QList<int> *qmlTypeIds,
941 const QMetaObject *classInfoMetaObject,
942 const QMetaObject *extensionMetaObject)
943{
945 3,
946 QMetaType(),
947 QMetaType(),
948 0,
949 nullptr,
950 nullptr,
951 nullptr,
952
953 uri,
955
957 (classInfoMetaObject ? classInfoMetaObject : metaObject),
958
959 nullptr,
960 nullptr,
961
962 -1,
963 -1,
964 -1,
965
966 nullptr,
967 extensionMetaObject,
968
969 &qmlCreateCustomParser<void>,
970 qmlTypeIds,
971 -1,
972 false,
974 };
975
977}
978
980 const char *uri, int versionMajor,
981 QList<int> *qmlTypeIds = nullptr,
982 const QMetaObject *classInfoMetaObject = nullptr)
983{
984 qmlRegisterNamespaceAndRevisions(metaObject, uri, versionMajor, qmlTypeIds,
985 classInfoMetaObject, nullptr);
986}
987
988int Q_QML_EXPORT qmlTypeId(const char *uri, int versionMajor, int versionMinor, const char *qmlName);
989
991
992#endif // QQML_H
The QJSEngine class provides an environment for evaluating JavaScript code.
Definition qjsengine.h:26
The QJSValue class acts as a container for Qt/JavaScript data types.
Definition qjsvalue.h:31
Definition qlist.h:74
void append(parameter_type t)
Definition qlist.h:441
\inmodule QtCore
\inmodule QtCore
Definition qmetatype.h:320
\inmodule QtCore
Definition qobject.h:90
The QQmlContext class defines a context within a QML engine.
Definition qqmlcontext.h:25
The QQmlCustomParser class allows you to add new arbitrary types to QML.
The QQmlEngine class provides an environment for instantiating QML components.
Definition qqmlengine.h:57
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
static constexpr QTypeRevision fromVersion(Major majorVersion, Minor minorVersion)
Produces a QTypeRevision from the given majorVersion and minorVersion, both of which need to be a val...
static constexpr QTypeRevision zero()
Produces a QTypeRevision with major and minor version {0}.
static constexpr QTypeRevision fromMinorVersion(Minor minorVersion)
Produces a QTypeRevision from the given minorVersion with an invalid major version.
static constexpr QTypeRevision fromMajorVersion(Major majorVersion)
Produces a QTypeRevision from the given majorVersion with an invalid minor version.
\inmodule QtCore
Definition qurl.h:94
bool isRelative() const
Returns true if the URL is relative; otherwise returns false.
Definition qurl.cpp:2797
void extension()
[6]
Definition dialogs.cpp:230
Q_QML_EXPORT void qmlRegistrationWarning(QmlRegistrationWarning warning, QMetaType type)
Definition qqml.cpp:149
@ CompositeSingletonRegistration
@ SingletonRegistration
@ SequentialContainerRegistration
@ CompositeRegistration
@ InterfaceRegistration
@ TypeAndRevisionsRegistration
@ UnconstructibleSingleton
int Q_QML_EXPORT qmlregister(RegistrationType, void *)
Definition qqml.cpp:483
Combined button and popup list for selecting options.
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
#define qWarning
Definition qlogging.h:162
const char * typeName
GLenum type
GLuint GLsizei const GLchar * message
GLhandleARB obj
[2]
GLenum func
Definition qopenglext.h:663
Q_QML_EXPORT QQmlEngine * qmlEngine(const QObject *)
Definition qqml.cpp:76
Q_QML_EXPORT void qmlRegisterModuleImport(const char *uri, int moduleMajor, const char *import, int importMajor=QQmlModuleImportLatest, int importMinor=QQmlModuleImportLatest)
QQmlCustomParser * qmlCreateCustomParser()
Definition qqmlprivate.h:85
Q_QML_EXPORT bool qmlProtectModule(const char *uri, int majVersion)
Definition qqml.cpp:218
int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
Definition qqml.h:300
int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString &reason)
Definition qqml.h:148
int qmlRegisterSingletonType(const char *uri, int versionMajor, int versionMinor, const char *typeName, QJSValue(*callback)(QQmlEngine *, QJSEngine *))
Definition qqml.h:673
void qmlRegisterAnonymousTypesAndRevisions(const char *uri, int versionMajor)
Definition qqml.h:128
int Q_QML_EXPORT qmlTypeId(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
Definition qqml.cpp:337
int qmlRegisterCustomExtendedType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, QQmlCustomParser *parser)
Definition qqml.h:584
int Q_QML_EXPORT qmlRegisterTypeNotAvailable(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString &message)
Definition qqml.cpp:759
void qmlRegisterNamespaceAndRevisions(const QMetaObject *metaObject, const char *uri, int versionMajor, QList< int > *qmlTypeIds, const QMetaObject *classInfoMetaObject, const QMetaObject *extensionMetaObject)
Definition qqml.h:938
void qmlRegisterTypesAndRevisions(const char *uri, int versionMajor, QList< int > *qmlTypeIds)
Definition qqml.h:925
@ QML_HAS_ATTACHED_PROPERTIES
Definition qqml.h:33
int qmlRegisterExtendedUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString &reason)
Definition qqml.h:216
int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, QQmlCustomParser *parser)
Definition qqml.h:510
int qmlRegisterExtendedType(const char *uri, int versionMajor)
Definition qqml.h:404
int qmlRegisterAnonymousSequentialContainer(const char *uri, int versionMajor)
Definition qqml.h:789
auto qmlRegisterSingletonInstance(const char *uri, int versionMajor, int versionMinor, const char *typeName, T *cppObject) -> typename std::enable_if< std::is_base_of< QObject, T >::value, int >::type
Definition qqml.h:741
Q_QML_EXPORT QObject * qmlExtendedObject(QObject *)
Definition qqml.cpp:125
QQmlModuleImportSpecialVersions
Definition qqml.h:647
@ QQmlModuleImportLatest
Definition qqml.h:649
@ QQmlModuleImportModuleAny
Definition qqml.h:648
@ QQmlModuleImportAuto
Definition qqml.h:650
int qmlRegisterRevision(const char *uri, int versionMajor, int versionMinor)
Definition qqml.h:372
QT_BEGIN_NAMESPACE void Q_QML_EXPORT qmlClearTypeRegistrations()
Definition qqml.cpp:210
Q_QML_EXPORT int qmlRegisterUncreatableMetaObject(const QMetaObject &staticMetaObject, const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString &reason)
Definition qqml.cpp:175
Q_QML_EXPORT QQmlAttachedPropertiesFunc qmlAttachedPropertiesFunction(QObject *, const QMetaObject *)
Definition qqml.cpp:102
Q_QML_EXPORT void qmlUnregisterModuleImport(const char *uri, int moduleMajor, const char *import, int importMajor=QQmlModuleImportLatest, int importMinor=QQmlModuleImportLatest)
int qmlRegisterAnonymousType(const char *uri, int versionMajor)
Definition qqml.h:56
Q_QML_EXPORT void qmlRegisterModule(const char *uri, int versionMajor, int versionMinor)
Definition qqml.cpp:225
Q_QML_EXPORT void qmlExecuteDeferred(QObject *)
Definition qqml.cpp:48
Q_QML_EXPORT QObject * qmlAttachedPropertiesObject(QObject *, QQmlAttachedPropertiesFunc func, bool create=true)
Definition qqml.cpp:110
Q_QML_EXPORT QQmlContext * qmlContext(const QObject *)
Definition qqml.cpp:71
int qmlRegisterInterface(const char *uri, int versionMajor)
Definition qqml.h:492
#define QML_UNCREATABLE(REASON)
#define QML_NAMED_ELEMENT(NAME)
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
QQmlPrivate::QQmlAttachedPropertiesFunc< QObject > QQmlAttachedPropertiesFunc
Definition qqmlprivate.h:62
#define Q_OBJECT
QUrl url("example.com")
[constructor-url-reference]
obj metaObject() -> className()
view create()
\inmodule QtCore
static QMetaType list()
static constexpr bool hasAcceptableCtors()
static QMetaType self()
static const QMetaObject * staticMetaObject()
static void registerTypeAndRevisions(const char *uri, int versionMajor, QList< int > *qmlTypeIds, const QMetaObject *extension)
Definition qqml.h:812
static void registerTypeAndRevisions(const char *uri, int versionMajor, QList< int > *qmlTypeIds, const QMetaObject *extension)
Definition qqml.h:843
static void registerTypeAndRevisions(const char *uri, int versionMajor, QList< int > *qmlTypeIds, const QMetaObject *extension)
Definition qqml.h:877
static void registerTypeAndRevisions(const char *uri, int versionMajor, QList< int > *qmlTypeIds, const QMetaObject *extension)
Definition qqml.h:903
static void registerTypeAndRevisions(const char *uri, int versionMajor, QList< int > *qmlTypeIds, const QMetaObject *)
Definition qqml.h:865
static void registerTypeAndRevisions(const char *uri, int versionMajor, QList< int > *qmlTypeIds, const QMetaObject *)
Definition qqml.h:915