QMetaObjectBuilder Class
The QMetaObjectBuilder class supports building QMetaObject objects at runtime. More...
Header: | #include <QMetaObjectBuilder> |
Public Types
enum | AddMember { ClassName, SuperClass, Methods, Signals, Slots, …, AllPrimaryMembers } |
flags | AddMembers |
StaticMetacallFunction |
Public Functions
QMetaObjectBuilder() | |
QMetaObjectBuilder(const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members = ...) | |
virtual | ~QMetaObjectBuilder() |
int | addClassInfo(const QByteArray &name, const QByteArray &value) |
QMetaMethodBuilder | addConstructor(const QByteArray &signature) |
QMetaMethodBuilder | addConstructor(const QMetaMethod &prototype) |
QMetaEnumBuilder | addEnumerator(const QByteArray &name) |
QMetaEnumBuilder | addEnumerator(const QMetaEnum &prototype) |
void | addMetaObject(const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members = AllMembers) |
QMetaMethodBuilder | addMethod(const QByteArray &signature) |
QMetaMethodBuilder | addMethod(const QByteArray &signature, const QByteArray &returnType) |
QMetaMethodBuilder | addMethod(const QMetaMethod &prototype) |
QMetaPropertyBuilder | addProperty(const QByteArray &name, const QByteArray &type, int notifierId = -1) |
QMetaPropertyBuilder | addProperty(const QByteArray &name, const QByteArray &type, QMetaType metaType, int notifierId = -1) |
QMetaPropertyBuilder | addProperty(const QMetaProperty &prototype) |
int | addRelatedMetaObject(const QMetaObject *meta) |
QMetaMethodBuilder | addSignal(const QByteArray &signature) |
QMetaMethodBuilder | addSlot(const QByteArray &signature) |
int | classInfoCount() const |
QByteArray | classInfoName(int index) const |
QByteArray | classInfoValue(int index) const |
QByteArray | className() const |
QMetaMethodBuilder | constructor(int index) const |
int | constructorCount() const |
QMetaEnumBuilder | enumerator(int index) const |
int | enumeratorCount() const |
MetaObjectFlags | flags() const |
int | indexOfClassInfo(const QByteArray &name) |
int | indexOfConstructor(const QByteArray &signature) |
int | indexOfEnumerator(const QByteArray &name) |
int | indexOfMethod(const QByteArray &signature) |
int | indexOfProperty(const QByteArray &name) |
int | indexOfSignal(const QByteArray &signature) |
int | indexOfSlot(const QByteArray &signature) |
QMetaMethodBuilder | method(int index) const |
int | methodCount() const |
QMetaPropertyBuilder | property(int index) const |
int | propertyCount() const |
const QMetaObject * | relatedMetaObject(int index) const |
int | relatedMetaObjectCount() const |
void | removeClassInfo(int index) |
void | removeConstructor(int index) |
void | removeEnumerator(int index) |
void | removeMethod(int index) |
void | removeProperty(int index) |
void | removeRelatedMetaObject(int index) |
void | setClassName(const QByteArray &name) |
void | setFlags(MetaObjectFlags flags) |
void | setStaticMetacallFunction(QMetaObjectBuilder::StaticMetacallFunction value) |
void | setSuperClass(const QMetaObject *meta) |
QMetaObjectBuilder::StaticMetacallFunction | staticMetacallFunction() const |
const QMetaObject * | superClass() const |
QMetaObject * | toMetaObject() const |
Detailed Description
\inmodule
QtCore \internal
Member Type Documentation
enum QMetaObjectBuilder::AddMember
flags QMetaObjectBuilder::AddMembers
This enum defines which members of QMetaObject should be copied by QMetaObjectBuilder::addMetaObject()
Constant | Value | Description |
---|---|---|
QMetaObjectBuilder::ClassName | 0x00000001 | Add the class name. |
QMetaObjectBuilder::SuperClass | 0x00000002 | Add the super class. |
QMetaObjectBuilder::Methods | 0x00000004 | Add methods that aren't signals or slots. |
QMetaObjectBuilder::Signals | 0x00000008 | Add signals. |
QMetaObjectBuilder::Slots | 0x00000010 | Add slots. |
QMetaObjectBuilder::Constructors | 0x00000020 | Add constructors. |
QMetaObjectBuilder::Properties | 0x00000040 | Add properties. |
QMetaObjectBuilder::Enumerators | 0x00000080 | Add enumerators. |
QMetaObjectBuilder::ClassInfos | 0x00000100 | Add items of class information. |
QMetaObjectBuilder::RelatedMetaObjects | 0x00000200 | Add related meta objects. |
QMetaObjectBuilder::StaticMetacall | 0x00000400 | Add the static metacall function. |
QMetaObjectBuilder::PublicMethods | 0x00000800 | Add public methods (ignored for signals). |
QMetaObjectBuilder::ProtectedMethods | 0x00001000 | Add protected methods (ignored for signals). |
QMetaObjectBuilder::PrivateMethods | 0x00002000 | All private methods (ignored for signals). |
QMetaObjectBuilder::AllMembers | 0x7FFFFFFF | Add all members. |
QMetaObjectBuilder::AllPrimaryMembers | 0x7FFFFBFC | Add everything except the class name, super class, and static metacall function. |
The AddMembers type is a typedef for QFlags<AddMember>. It stores an OR combination of AddMember values.
QMetaObjectBuilder::StaticMetacallFunction
Typedef for static metacall functions. The three parameters are the call type value, the constructor index, and the array of parameters.
Member Function Documentation
QMetaObjectBuilder::QMetaObjectBuilder()
Constructs a new QMetaObjectBuilder.
[explicit]
QMetaObjectBuilder::QMetaObjectBuilder(const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members = ...)
Constructs a new QMetaObjectBuilder which is a copy of the meta object information in prototype. Note: the super class contents for prototype are not copied, only the immediate class that is defined by prototype.
The members parameter indicates which members of prototype should be added. The default is AllMembers.
See also addMetaObject().
[virtual noexcept]
QMetaObjectBuilder::~QMetaObjectBuilder()
Destroys this meta object builder.
int QMetaObjectBuilder::addClassInfo(const QByteArray &name, const QByteArray &value)
Adds name and value as an item of class information to this class. Returns the index of the new item of class information.
See also classInfoCount(), classInfoName(), classInfoValue(), removeClassInfo(), and indexOfClassInfo().
QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QByteArray &signature)
Adds a new constructor to this class with the specified signature. Returns an object that can be used to adjust the other attributes of the constructor. The signature will be normalized before it is added to the class.
See also constructor(), constructorCount(), removeConstructor(), and indexOfConstructor().
QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QMetaMethod &prototype)
Adds a new constructor to this class that has the same information as prototype. This is used to clone the constructors of an existing QMetaObject. Returns an object that can be used to adjust the attributes of the constructor.
This function requires that prototype be a constructor.
See also constructor(), constructorCount(), removeConstructor(), and indexOfConstructor().
QMetaEnumBuilder QMetaObjectBuilder::addEnumerator(const QByteArray &name)
Adds a new enumerator to this class with the specified name. Returns an object that can be used to adjust the other attributes of the enumerator.
See also enumerator(), enumeratorCount(), removeEnumerator(), and indexOfEnumerator().
QMetaEnumBuilder QMetaObjectBuilder::addEnumerator(const QMetaEnum &prototype)
Adds a new enumerator to this class that has the same information as prototype. This is used to clone the enumerators of an existing QMetaObject. Returns an object that can be used to adjust the attributes of the enumerator.
See also enumerator(), enumeratorCount(), removeEnumerator(), and indexOfEnumerator().
void QMetaObjectBuilder::addMetaObject(const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members = AllMembers)
Adds the contents of prototype to this meta object builder. This function is useful for cloning the contents of an existing QMetaObject.
The members parameter indicates which members of prototype should be added. The default is AllMembers.
QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QByteArray &signature)
Adds a new public method to this class with the specified signature. Returns an object that can be used to adjust the other attributes of the method. The signature will be normalized before it is added to the class.
See also method(), methodCount(), removeMethod(), and indexOfMethod().
QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QByteArray &signature, const QByteArray &returnType)
Adds a new public method to this class with the specified signature and returnType. Returns an object that can be used to adjust the other attributes of the method. The signature and returnType will be normalized before they are added to the class.
See also method(), methodCount(), removeMethod(), and indexOfMethod().
QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QMetaMethod &prototype)
Adds a new public method to this class that has the same information as prototype. This is used to clone the methods of an existing QMetaObject. Returns an object that can be used to adjust the attributes of the method.
This function will detect if prototype is an ordinary method, signal, slot, or constructor and act accordingly.
See also method(), methodCount(), removeMethod(), and indexOfMethod().
QMetaPropertyBuilder QMetaObjectBuilder::addProperty(const QByteArray &name, const QByteArray &type, int notifierId = -1)
Adds a new readable/writable property to this class with the specified name and type. Returns an object that can be used to adjust the other attributes of the property. The type will be normalized before it is added to the class. notifierId will be registered as the property's notify signal.
See also property(), propertyCount(), removeProperty(), and indexOfProperty().
QMetaPropertyBuilder QMetaObjectBuilder::addProperty(const QByteArray &name, const QByteArray &type, QMetaType metaType, int notifierId = -1)
This is an overloaded function.
QMetaPropertyBuilder QMetaObjectBuilder::addProperty(const QMetaProperty &prototype)
Adds a new property to this class that has the same information as prototype. This is used to clone the properties of an existing QMetaObject. Returns an object that can be used to adjust the attributes of the property.
See also property(), propertyCount(), removeProperty(), and indexOfProperty().
int QMetaObjectBuilder::addRelatedMetaObject(const QMetaObject *meta)
Adds meta to this class as a related meta object. Returns the index of the new related meta object entry.
Related meta objects are used when resolving the enumerated type associated with a property, where the enumerated type is in a different class from the property.
See also relatedMetaObjectCount(), relatedMetaObject(), and removeRelatedMetaObject().
QMetaMethodBuilder QMetaObjectBuilder::addSignal(const QByteArray &signature)
Adds a new signal to this class with the specified signature. Returns an object that can be used to adjust the other attributes of the signal. The signature will be normalized before it is added to the class.
See also addMethod(), addSlot(), and indexOfSignal().
QMetaMethodBuilder QMetaObjectBuilder::addSlot(const QByteArray &signature)
Adds a new public slot to this class with the specified signature. Returns an object that can be used to adjust the other attributes of the slot. The signature will be normalized before it is added to the class.
See also addMethod(), addSignal(), and indexOfSlot().
int QMetaObjectBuilder::classInfoCount() const
Returns the number of items of class information in this class, exclusing the number of items of class information in the base class.
See also addClassInfo(), classInfoName(), classInfoValue(), removeClassInfo(), and indexOfClassInfo().
QByteArray QMetaObjectBuilder::classInfoName(int index) const
Returns the name of the item of class information at index in this class.
See also classInfoCount(), addClassInfo(), classInfoValue(), removeClassInfo(), and indexOfClassInfo().
QByteArray QMetaObjectBuilder::classInfoValue(int index) const
Returns the value of the item of class information at index in this class.
See also classInfoCount(), addClassInfo(), classInfoName(), removeClassInfo(), and indexOfClassInfo().
QByteArray QMetaObjectBuilder::className() const
Returns the name of the class being constructed by this meta object builder. The default value is an empty QByteArray.
See also setClassName() and superClass().
QMetaMethodBuilder QMetaObjectBuilder::constructor(int index) const
Returns the constructor at index in this class.
See also methodCount(), addMethod(), removeMethod(), and indexOfConstructor().
int QMetaObjectBuilder::constructorCount() const
Returns the number of constructors in this class.
See also addConstructor(), constructor(), removeConstructor(), and indexOfConstructor().
QMetaEnumBuilder QMetaObjectBuilder::enumerator(int index) const
Returns the enumerator at index in this class.
See also enumeratorCount(), addEnumerator(), removeEnumerator(), and indexOfEnumerator().
int QMetaObjectBuilder::enumeratorCount() const
Returns the number of enumerators in this class, excluding the number of enumerators in the base class.
See also addEnumerator(), enumerator(), removeEnumerator(), and indexOfEnumerator().
MetaObjectFlags QMetaObjectBuilder::flags() const
Returns the flags of the class being constructed by this meta object builder.
See also setFlags().
int QMetaObjectBuilder::indexOfClassInfo(const QByteArray &name)
Finds an item of class information with the specified name and returns its index; otherwise returns -1.
See also classInfoName(), classInfoValue(), classInfoCount(), addClassInfo(), and removeClassInfo().
int QMetaObjectBuilder::indexOfConstructor(const QByteArray &signature)
Finds a constructor with the specified signature and returns its index; otherwise returns -1. The signature will be normalized by this method.
See also constructor(), constructorCount(), addConstructor(), and removeConstructor().
int QMetaObjectBuilder::indexOfEnumerator(const QByteArray &name)
Finds an enumerator with the specified name and returns its index; otherwise returns -1.
See also enumertor(), enumeratorCount(), addEnumerator(), and removeEnumerator().
int QMetaObjectBuilder::indexOfMethod(const QByteArray &signature)
Finds a method with the specified signature and returns its index; otherwise returns -1. The signature will be normalized by this method.
See also method(), methodCount(), addMethod(), and removeMethod().
int QMetaObjectBuilder::indexOfProperty(const QByteArray &name)
Finds a property with the specified name and returns its index; otherwise returns -1.
See also property(), propertyCount(), addProperty(), and removeProperty().
int QMetaObjectBuilder::indexOfSignal(const QByteArray &signature)
Finds a signal with the specified signature and returns its index; otherwise returns -1. The signature will be normalized by this method.
See also indexOfMethod() and indexOfSlot().
int QMetaObjectBuilder::indexOfSlot(const QByteArray &signature)
Finds a slot with the specified signature and returns its index; otherwise returns -1. The signature will be normalized by this method.
See also indexOfMethod() and indexOfSignal().
QMetaMethodBuilder QMetaObjectBuilder::method(int index) const
Returns the method at index in this class.
See also methodCount(), addMethod(), removeMethod(), and indexOfMethod().
int QMetaObjectBuilder::methodCount() const
Returns the number of methods in this class, excluding the number of methods in the base class. These include signals and slots as well as normal member functions.
See also addMethod(), method(), removeMethod(), and indexOfMethod().
QMetaPropertyBuilder QMetaObjectBuilder::property(int index) const
Returns the property at index in this class.
See also methodCount(), addMethod(), removeMethod(), and indexOfProperty().
int QMetaObjectBuilder::propertyCount() const
Returns the number of properties in this class, excluding the number of properties in the base class.
See also addProperty(), property(), removeProperty(), and indexOfProperty().
const QMetaObject *QMetaObjectBuilder::relatedMetaObject(int index) const
Returns the related meta object at index in this class.
Related meta objects are used when resolving the enumerated type associated with a property, where the enumerated type is in a different class from the property.
See also relatedMetaObjectCount(), addRelatedMetaObject(), and removeRelatedMetaObject().
int QMetaObjectBuilder::relatedMetaObjectCount() const
Returns the number of related meta objects that are associated with this class.
Related meta objects are used when resolving the enumerated type associated with a property, where the enumerated type is in a different class from the property.
See also addRelatedMetaObject(), relatedMetaObject(), and removeRelatedMetaObject().
void QMetaObjectBuilder::removeClassInfo(int index)
Removes the item of class information at index from this class. The indices of all following items will be adjusted downwards by 1.
See also classInfoCount(), addClassInfo(), classInfoName(), classInfoValue(), and indexOfClassInfo().
void QMetaObjectBuilder::removeConstructor(int index)
Removes the constructor at index from this class. The indices of all following constructors will be adjusted downwards by 1.
See also constructorCount(), addConstructor(), constructor(), and indexOfConstructor().
void QMetaObjectBuilder::removeEnumerator(int index)
Removes the enumerator at index from this class. The indices of all following enumerators will be adjusted downwards by 1.
See also enumertorCount(), addEnumerator(), enumerator(), and indexOfEnumerator().
void QMetaObjectBuilder::removeMethod(int index)
Removes the method at index from this class. The indices of all following methods will be adjusted downwards by 1. If the method is registered as a notify signal on a property, then the notify signal will be removed from the property.
See also methodCount(), addMethod(), method(), and indexOfMethod().
void QMetaObjectBuilder::removeProperty(int index)
Removes the property at index from this class. The indices of all following properties will be adjusted downwards by 1.
See also propertyCount(), addProperty(), property(), and indexOfProperty().
void QMetaObjectBuilder::removeRelatedMetaObject(int index)
Removes the related meta object at index from this class. The indices of all following related meta objects will be adjusted downwards by 1.
Related meta objects are used when resolving the enumerated type associated with a property, where the enumerated type is in a different class from the property.
See also relatedMetaObjectCount(), addRelatedMetaObject(), and relatedMetaObject().
void QMetaObjectBuilder::setClassName(const QByteArray &name)
Sets the name of the class being constructed by this meta object builder.
See also className() and setSuperClass().
void QMetaObjectBuilder::setFlags(MetaObjectFlags flags)
Sets the flags of the class being constructed by this meta object builder.
See also flags().
void QMetaObjectBuilder::setStaticMetacallFunction(QMetaObjectBuilder::StaticMetacallFunction value)
Sets the static metacall function to use to construct objects of this class to value. The default value is null.
See also staticMetacallFunction().
void QMetaObjectBuilder::setSuperClass(const QMetaObject *meta)
Sets the superclass meta object of the class being constructed by this meta object builder to meta. The meta parameter must not be null.
See also superClass() and setClassName().
QMetaObjectBuilder::StaticMetacallFunction QMetaObjectBuilder::staticMetacallFunction() const
Returns the static metacall function to use to construct objects of this class. The default value is null.
See also setStaticMetacallFunction().
const QMetaObject *QMetaObjectBuilder::superClass() const
Returns the superclass meta object of the class being constructed by this meta object builder. The default value is the meta object for QObject.
See also setSuperClass() and className().
QMetaObject *QMetaObjectBuilder::toMetaObject() const
Converts this meta object builder into a concrete QMetaObject. The return value should be deallocated using free() once it is no longer needed.
The returned meta object is a snapshot of the state of the QMetaObjectBuilder. Any further modifications to the QMetaObjectBuilder will not be reflected in previous meta objects returned by this method.