CopperSpice API
1.9.1
|
The QMetaObject class stores meta information about objects. More...
Public Methods | |
virtual QMetaClassInfo | classInfo (int index) const = 0 |
virtual int | classInfoCount () const = 0 |
int | classInfoOffset () const |
virtual const QString & | className () const = 0 |
virtual QMetaMethod | constructor (int index) const = 0 |
virtual int | constructorCount () const = 0 |
virtual QMetaEnum | enumerator (int index) const = 0 |
virtual int | enumeratorCount () const = 0 |
int | enumeratorOffset () const |
int | indexOfClassInfo (const QString &name) const |
int | indexOfConstructor (const QString &constructor) const |
int | indexOfEnumerator (const QString &name) const |
int | indexOfMethod (const QString &method) const |
int | indexOfProperty (const QString &name) const |
int | indexOfSignal (const QString &signal) const |
int | indexOfSlot (const QString &slot) const |
virtual QMetaMethod | method (int index) const = 0 |
virtual int | methodCount () const = 0 |
int | methodOffset () const |
template<class... Ts> | |
QObject * | newInstance (Ts...Vs) const |
virtual QMetaProperty | property (int index) const = 0 |
virtual int | propertyCount () const = 0 |
int | propertyOffset () const |
virtual const QMetaObject * | superClass () const = 0 |
QString | tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >()) const |
QString | tr (const QString &text, const QString &comment=QString (), std::optional< int > numArg=std::optional< int >()) const |
QMetaProperty | userProperty () const |
Static Public Methods | |
static bool | checkConnectArgs (const QString &signal, const QString &method) |
static void | connectSlotsByName (QObject *object) |
template<class... Ts> | |
static bool | invokeMethod (QObject *object, const QString &member, CSArgument< Ts >...Vs) |
template<class R , class... Ts> | |
static bool | invokeMethod (QObject *object, const QString &member, CSReturnArgument< R > retval, CSArgument< Ts >...Vs) |
template<class... Ts> | |
static bool | invokeMethod (QObject *object, const QString &member, Qt::ConnectionType type, CSArgument< Ts >...Vs) |
template<class R , class... Ts> | |
static bool | invokeMethod (QObject *object, const QString &member, Qt::ConnectionType type, CSReturnArgument< R > retval, CSArgument< Ts >...Vs) |
static QString | normalizedSignature (const QString &method) |
static QString | normalizedType (const QString &type) |
The QMetaObject class stores meta information about objects.
The CopperSpice Meta Object System is responsible for the signals and slots inter-object communication mechanism, runtime type information, and the CopperSpice property system. A single QMetaObject instance is created for each QObject subclass that is used in an application, and this instance stores all the meta information for the QObject subclass. This object is available as QObject::metaObject().
The most commonly used methods are shown below.
The index methods indexOfConstructor(), indexOfMethod(), indexOfEnumerator(), and indexOfProperty() map names of constructors, methods, enumerators, or properties to indexes in the meta object.
Classes can also have a list of name / value pairs of additional class information which is stored in QMetaClassInfo objects. The number of pairs is returned by classInfoCount() and single pairs are returned by classInfo(). You can search for pairs using the indexOfClassInfo() method.
Returns true if the signal and method arguments are compatible, otherwise returns false. Both signal and method are expected to be normalized.
|
pure virtual |
Returns the meta data for the item of class information with the given index.
|
pure virtual |
Returns the number of items of class information in this class.
int QMetaObject::classInfoOffset | ( | ) | const |
Returns the class information offset for this class. If the class has no parent with class information the offset is 0, otherwise the offset is the sum of all the class information items in all parent classes.
|
pure virtual |
Returns the class name.
|
static |
This method searches recursively for all child objects of the specified object and creates a connection from any matching signal to the corresponding slot.
For example, assume the given object has a child named myButton which is of type QPushButton. If you have a slot declared as shown below this method will create the connection automatically.
|
pure virtual |
Returns the meta data for the constructor with the given index.
|
pure virtual |
Returns the number of constructors in this class.
|
pure virtual |
Returns the meta data for the enumerator with the given index.
|
pure virtual |
Returns the number of enumerators in this class.
int QMetaObject::enumeratorOffset | ( | ) | const |
Returns the enumerator offset for this class. If the class has no parents with enumerators the offset is 0, otherwise the offset is the sum of all the enumerators in all parent classes.
int QMetaObject::indexOfClassInfo | ( | const QString & | name | ) | const |
Finds class information item name and returns its index, otherwise returns -1.
int QMetaObject::indexOfConstructor | ( | const QString & | constructor | ) | const |
Finds constructor and returns its index, otherwise returns -1. The constructor must be in normalized form as returned by normalizedSignature().
int QMetaObject::indexOfEnumerator | ( | const QString & | name | ) | const |
Finds enumerator name and returns its index, otherwise returns -1.
int QMetaObject::indexOfMethod | ( | const QString & | method | ) | const |
Finds method and returns its index, otherwise returns -1. The method must be in normalized form as returned by normalizedSignature().
int QMetaObject::indexOfProperty | ( | const QString & | name | ) | const |
Finds property name and returns its index, otherwise returns -1.
int QMetaObject::indexOfSignal | ( | const QString & | signal | ) | const |
Finds signal and returns its index, otherwise returns -1. The signal must be in normalized form, as returned by normalizedSignature(). This is the same as indexOfMethod() except it will return -1 if the method exists but is not a signal.
int QMetaObject::indexOfSlot | ( | const QString & | slot | ) | const |
Finds slot and returns its index, otherwise returns -1. This is the same as indexOfMethod(), except that it will return -1 if the method exists but is not a slot.
|
static |
This overload invokes the member using the connection type Qt::AutoConnection and ignores return values.
|
static |
This overload always invokes the member using the connection type Qt::AutoConnection.
|
static |
This overload can be used if the return value of the member is of no interest.
|
static |
Invokes the member (a signal or a slot name) on the given object. Returns true if the member could be invoked. Returns false if there is no such member or the parameters did not match. The invocation can be either synchronous or asynchronous, depending on the given type.
The return value is placed in retval. You must enclose the return value in a Q_RETURN_ARG() macro. Q_RETURN_ARG() takes a type name and a non-const reference. If the invocation is asynchronous there is no return value. You only need to pass the name of the signal or slot to this method not the entire signature. For example, to asynchronously invoke the animateClick() slot on a QPushButton, use the following code.
To synchronously invoke the compute(QString, int, double)
slot on some arbitrary object obj
retrieve its return value. If the "compute" slot does not take exactly one QString, one int, and one double in the specified order, the call will fail.
|
pure virtual |
Returns the meta data for the method with the given index.
|
pure virtual |
Returns the number of methods known to the meta object system in this class, including the number of properties provided by each base class. These include signals and slots as well as member functions declared with the CS_INVOKABLE() macro.
Use code like the following to obtain a QStringList containing the methods specific to a given class.
int QMetaObject::methodOffset | ( | ) | const |
Returns the method offset for this class. The offset is the sum of all the methods in the class superclasses (which is always positive since QObject has the deleteLater() slot and a destroyed() signal).
QObject * QMetaObject::newInstance | ( | Ts... | Vs | ) | const |
Constructs a new instance of this class. Returns the new object or a nullptr if no suitable constructor is available. Only constructors that are declared with the CS_INVOKABLE() modifier are made available through the meta object system.
Normalizes the signature of the given method.
CopperSpice uses normalized signatures to decide whether a given signal and slot are compatible. Normalization reduces whitespace to a minimum, moves 'const' to the front where appropriate, removes 'const' from value types, and for a parameter replaces a const reference with a value.
|
pure virtual |
Returns the meta data for the property with the given index. If no such property exists, a null QMetaProperty is returned.
|
pure virtual |
Returns the number of properties in this class, including the number of properties provided by each base class. The following example can be used to obtain a QStringList containing the properties specific to a given class.
int QMetaObject::propertyOffset | ( | ) | const |
Returns the property offset for this class. The offset is the sum of all the properties in the class superclasses (which is always positive since QObject has the name() property).
|
pure virtual |
Returns the meta object of the superclass or nullptr if there is no object.
QString QMetaObject::tr | ( | const char * | text, |
const char * | comment = nullptr , |
||
std::optional< int > | numArg = std::optional<int>() |
||
) | const |
Returns a translated version of text which is based on the given comment and the value of numArg for translations containing numbers. Returns the original given text if no translation is available.
QString QMetaObject::tr | ( | const QString & | text, |
const QString & | comment = QString() , |
||
std::optional< int > | numArg = std::optional<int>() |
||
) | const |
Returns a translated version of text which is based on the given comment and the value of numArg for translations containing numbers. Returns the original given text if no translation is available.
QMetaProperty QMetaObject::userProperty | ( | ) | const |
Returns the property where the USER
flag is set to true. There should be only one property with the User flag set for a particular class and any parent classes.