QMetaObject#
Synopsis#
Functions#
def
__repr__
()def
cast
(obj)def
cast
(obj)def
classInfo
(index)def
classInfoCount
()def
classInfoOffset
()def
className
()def
constructor
(index)def
constructorCount
()def
enumerator
(index)def
enumeratorCount
()def
enumeratorOffset
()def
indexOfClassInfo
(name)def
indexOfConstructor
(constructor)def
indexOfEnumerator
(name)def
indexOfMethod
(method)def
indexOfProperty
(name)def
indexOfSignal
(signal)def
indexOfSlot
(slot)def
inherits
(metaObject)def
metaType
()def
method
(index)def
methodCount
()def
methodOffset
()def
newInstance
([val0=QGenericArgument(nullptr)[, val1=QGenericArgument()[, val2=QGenericArgument()[, val3=QGenericArgument()[, val4=QGenericArgument()[, val5=QGenericArgument()[, val6=QGenericArgument()[, val7=QGenericArgument()[, val8=QGenericArgument()[, val9=QGenericArgument()]]]]]]]]]])def
property
(index)def
propertyCount
()def
propertyOffset
()def
superClass
()def
userProperty
()
Static functions#
def
checkConnectArgs
(signal, method)def
checkConnectArgs
(signal, method)def
connectSlotsByName
(o)def
disconnect
(sender, signal_index, receiver, method_index)def
disconnectOne
(sender, signal_index, receiver, method_index)def
invokeMethod
(obj, member, arg__3, ret[, val0=QGenericArgument(nullptr)[, val1=QGenericArgument()[, val2=QGenericArgument()[, val3=QGenericArgument()[, val4=QGenericArgument()[, val5=QGenericArgument()[, val6=QGenericArgument()[, val7=QGenericArgument()[, val8=QGenericArgument()[, val9=QGenericArgument()]]]]]]]]]])def
invokeMethod
(obj, member, ret[, val0=QGenericArgument(nullptr)[, val1=QGenericArgument()[, val2=QGenericArgument()[, val3=QGenericArgument()[, val4=QGenericArgument()[, val5=QGenericArgument()[, val6=QGenericArgument()[, val7=QGenericArgument()[, val8=QGenericArgument()[, val9=QGenericArgument()]]]]]]]]]])def
invokeMethod
(obj, member, type[, val0=QGenericArgument(nullptr)[, val1=QGenericArgument()[, val2=QGenericArgument()[, val3=QGenericArgument()[, val4=QGenericArgument()[, val5=QGenericArgument()[, val6=QGenericArgument()[, val7=QGenericArgument()[, val8=QGenericArgument()[, val9=QGenericArgument()]]]]]]]]]])def
invokeMethod
(obj, member[, val0=QGenericArgument(nullptr)[, val1=QGenericArgument()[, val2=QGenericArgument()[, val3=QGenericArgument()[, val4=QGenericArgument()[, val5=QGenericArgument()[, val6=QGenericArgument()[, val7=QGenericArgument()[, val8=QGenericArgument()[, val9=QGenericArgument()]]]]]]]]]])def
invokeMethod
(object, member, ret[, val0={}[, val1={}[, val2={}]]])def
invokeMethod
(object, member, type, ret[, val0={}[, val1={}[, val2={}]]])def
invokeMethod
(object, member, type[, val0={}[, val1={}[, val2={}]]])def
invokeMethod
(object, member[, val0={}[, val1={}[, val2={}]]])def
normalizedSignature
(method)def
normalizedType
(type)
Detailed Description#
Represents a handle to a signal-slot (or signal-functor) connection.
It can be used to check if the connection is valid and to disconnect it using disconnect()
. For a signal-functor connection without a context object, it is the only way to selectively disconnect that connection.
As Connection is just a handle, the underlying signal-slot connection is unaffected when Connection is destroyed or reassigned.
- class PySide6.QtCore.QMetaObject#
- PySide6.QtCore.QMetaObject.Call#
- PySide6.QtCore.QMetaObject.__repr__()#
- Return type
object
- PySide6.QtCore.QMetaObject.cast(obj)#
- Parameters
obj –
PySide6.QtCore.QObject
- Return type
- PySide6.QtCore.QMetaObject.cast(obj)
- Parameters
obj –
PySide6.QtCore.QObject
- Return type
- static PySide6.QtCore.QMetaObject.checkConnectArgs(signal, method)#
- Parameters
signal –
PySide6.QtCore.QMetaMethod
method –
PySide6.QtCore.QMetaMethod
- Return type
bool
This is an overloaded function.
Returns true
if the signal
and method
arguments are compatible; otherwise returns false
.
- static PySide6.QtCore.QMetaObject.checkConnectArgs(signal, method)
- Parameters
signal – str
method – str
- Return type
bool
Returns true
if the signal
and method
arguments are compatible; otherwise returns false
.
Both signal
and method
are expected to be normalized.
See also
- PySide6.QtCore.QMetaObject.classInfo(index)#
- Parameters
index – int
- Return type
Returns the meta-data for the item of class information with the given index
.
Example:
class MyClass(QObject): Q_OBJECT Q_CLASSINFO("author", "Sabrina Schweinsteiger") Q_CLASSINFO("url", "http://doc.moosesoft.co.uk/1.0/") # public ...
- PySide6.QtCore.QMetaObject.classInfoCount()#
- Return type
int
Returns the number of items of class information in this class.
- PySide6.QtCore.QMetaObject.classInfoOffset()#
- Return type
int
Returns the class information offset for this class; i.e. the index position of this class’s first class information item.
If the class has no superclasses with class information, the offset is 0; otherwise the offset is the sum of all the class information items in the class’s superclasses.
- PySide6.QtCore.QMetaObject.className()#
- Return type
str
Returns the class name.
See also
- static PySide6.QtCore.QMetaObject.connectSlotsByName(o)#
- Parameters
Searches recursively for all child objects of the given object
, and connects matching signals from them to slots of object
that follow the following form:
on_<object = void(<signal parameters>)
Let’s assume our object has a child object of type QPushButton
with the object name
button1
. The slot to catch the button’s clicked()
signal would be:
def on_button1_clicked():
If object
itself has a properly set object name, its own signals are also connected to its respective slots.
See also
- PySide6.QtCore.QMetaObject.constructor(index)#
- Parameters
index – int
- Return type
Returns the meta-data for the constructor with the given index
.
See also
- PySide6.QtCore.QMetaObject.constructorCount()#
- Return type
int
Returns the number of constructors in this class.
See also
- static PySide6.QtCore.QMetaObject.disconnect(sender, signal_index, receiver, method_index)#
- Parameters
sender –
PySide6.QtCore.QObject
signal_index – int
receiver –
PySide6.QtCore.QObject
method_index – int
- Return type
bool
- static PySide6.QtCore.QMetaObject.disconnectOne(sender, signal_index, receiver, method_index)#
- Parameters
sender –
PySide6.QtCore.QObject
signal_index – int
receiver –
PySide6.QtCore.QObject
method_index – int
- Return type
bool
- PySide6.QtCore.QMetaObject.enumerator(index)#
- Parameters
index – int
- Return type
Returns the meta-data for the enumerator with the given index
.
- PySide6.QtCore.QMetaObject.enumeratorCount()#
- Return type
int
Returns the number of enumerators in this class.
- PySide6.QtCore.QMetaObject.enumeratorOffset()#
- Return type
int
Returns the enumerator offset for this class; i.e. the index position of this class’s first enumerator.
If the class has no superclasses with enumerators, the offset is 0; otherwise the offset is the sum of all the enumerators in the class’s superclasses.
- PySide6.QtCore.QMetaObject.indexOfClassInfo(name)#
- Parameters
name – str
- Return type
int
Finds class information item name
and returns its index; otherwise returns -1.
See also
- PySide6.QtCore.QMetaObject.indexOfConstructor(constructor)#
- Parameters
constructor – str
- Return type
int
Finds constructor
and returns its index; otherwise returns -1.
Note that the constructor
has to be in normalized form, as returned by normalizedSignature()
.
- PySide6.QtCore.QMetaObject.indexOfEnumerator(name)#
- Parameters
name – str
- Return type
int
Finds enumerator name
and returns its index; otherwise returns -1.
- PySide6.QtCore.QMetaObject.indexOfMethod(method)#
- Parameters
method – str
- Return type
int
Finds method
and returns its index; otherwise returns -1.
Note that the method
has to be in normalized form, as returned by normalizedSignature()
.
- PySide6.QtCore.QMetaObject.indexOfProperty(name)#
- Parameters
name – str
- Return type
int
Finds property name
and returns its index; otherwise returns -1.
See also
- PySide6.QtCore.QMetaObject.indexOfSignal(signal)#
- Parameters
signal – str
- Return type
int
Finds signal
and returns its index; otherwise returns -1.
This is the same as indexOfMethod()
, except that it will return -1 if the method exists but isn’t a signal.
Note that the signal
has to be in normalized form, as returned by normalizedSignature()
.
- PySide6.QtCore.QMetaObject.indexOfSlot(slot)#
- Parameters
slot – str
- Return type
int
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 isn’t a slot.
- PySide6.QtCore.QMetaObject.inherits(metaObject)#
- Parameters
metaObject –
PySide6.QtCore.QMetaObject
- Return type
bool
Returns true
if the class described by this QMetaObject
inherits the type described by metaObject
; otherwise returns false.
A type is considered to inherit itself.
- static PySide6.QtCore.QMetaObject.invokeMethod(obj, member[, val0=QGenericArgument(nullptr)[, val1=QGenericArgument()[, val2=QGenericArgument()[, val3=QGenericArgument()[, val4=QGenericArgument()[, val5=QGenericArgument()[, val6=QGenericArgument()[, val7=QGenericArgument()[, val8=QGenericArgument()[, val9=QGenericArgument()]]]]]]]]]])#
- Parameters
obj –
PySide6.QtCore.QObject
member – str
- Return type
bool
This function overloads invokeMethod()
.
This overload invokes the member using the connection type AutoConnection
and ignores return values.
- static PySide6.QtCore.QMetaObject.invokeMethod(obj, member, ret[, val0=QGenericArgument(nullptr)[, val1=QGenericArgument()[, val2=QGenericArgument()[, val3=QGenericArgument()[, val4=QGenericArgument()[, val5=QGenericArgument()[, val6=QGenericArgument()[, val7=QGenericArgument()[, val8=QGenericArgument()[, val9=QGenericArgument()]]]]]]]]]])
- Parameters
obj –
PySide6.QtCore.QObject
member – str
- Return type
bool
This function overloads invokeMethod()
.
This overload always invokes the member using the connection type AutoConnection
.
- static PySide6.QtCore.QMetaObject.invokeMethod(obj, member, arg__3, ret[, val0=QGenericArgument(nullptr)[, val1=QGenericArgument()[, val2=QGenericArgument()[, val3=QGenericArgument()[, val4=QGenericArgument()[, val5=QGenericArgument()[, val6=QGenericArgument()[, val7=QGenericArgument()[, val8=QGenericArgument()[, val9=QGenericArgument()]]]]]]]]]])
- Parameters
obj –
PySide6.QtCore.QObject
member – str
arg__3 –
ConnectionType
- Return type
bool
Invokes the member
(a signal or a slot name) on the object obj
. 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 type
:
If
type
isDirectConnection
, the member will be invoked immediately.If
type
isQueuedConnection
, aQEvent
will be sent and the member is invoked as soon as the application enters the main event loop.If
type
isBlockingQueuedConnection
, the method will be invoked in the same way as forQueuedConnection
, except that the current thread will block until the event is delivered. Using this connection type to communicate between objects in the same thread will lead to deadlocks.If
type
isAutoConnection
, the member is invoked synchronously ifobj
lives in the same thread as the caller; otherwise it will invoke the member asynchronously.
The return value of the member
function call is placed in ret
. If the invocation is asynchronous, the return value cannot be evaluated. You can pass up to ten arguments (val0
, val1
, val2
, val3
, val4
, val5
, val6
, val7
, val8
, and val9
) to the member
function.
QGenericArgument
and QGenericReturnArgument
are internal helper classes. Because signals and slots can be dynamically invoked, you must enclose the arguments using the Q_ARG()
and Q_RETURN_ARG()
macros. Q_ARG()
takes a type name and a const reference of that type; Q_RETURN_ARG()
takes a type name and a non-const reference.
You only need to pass the name of the signal or slot to this function, not the entire signature. For example, to asynchronously invoke the quit()
slot on a QThread
, use the following code:
QMetaObject.invokeMethod(thread, "quit", Qt.QueuedConnection)
With asynchronous method invocations, the parameters must be of types that are known to Qt’s meta-object system, because Qt needs to copy the arguments to store them in an event behind the scenes. If you try to use a queued connection and get the error message
QMetaObject.invokeMethod: Unable to handle unregistered datatype 'MyType'
call qRegisterMetaType()
to register the data type before you call invokeMethod().
To synchronously invoke the compute(QString, int, double)
slot on some arbitrary object obj
retrieve its return value:
retVal = QString() QMetaObject.invokeMethod(obj, "compute", Qt.DirectConnection, Q_RETURN_ARG(QString, retVal), Q_ARG(QString, "sqrt"), Q_ARG(int, 42), Q_ARG(double, 9.7))
If the “compute” slot does not take exactly one QString
, one int and one double in the specified order, the call will fail.
See also
Q_ARG()
Q_RETURN_ARG()
qRegisterMetaType()
invoke()
- static PySide6.QtCore.QMetaObject.invokeMethod(obj, member, type[, val0=QGenericArgument(nullptr)[, val1=QGenericArgument()[, val2=QGenericArgument()[, val3=QGenericArgument()[, val4=QGenericArgument()[, val5=QGenericArgument()[, val6=QGenericArgument()[, val7=QGenericArgument()[, val8=QGenericArgument()[, val9=QGenericArgument()]]]]]]]]]])
- Parameters
obj –
PySide6.QtCore.QObject
member – str
type –
ConnectionType
- Return type
bool
This function overloads invokeMethod()
.
This overload can be used if the return value of the member is of no interest.
- static PySide6.QtCore.QMetaObject.invokeMethod(object, member, type[, val0={}[, val1={}[, val2={}]]])
- Parameters
object –
PySide6.QtCore.QObject
member – str
type –
ConnectionType
val0 –
QGenericArgumentHolder
val1 –
QGenericArgumentHolder
val2 –
QGenericArgumentHolder
- Return type
bool
- static PySide6.QtCore.QMetaObject.invokeMethod(object, member, type, ret[, val0={}[, val1={}[, val2={}]]])
- Parameters
object –
PySide6.QtCore.QObject
member – str
type –
ConnectionType
ret –
QGenericReturnArgumentHolder
val0 –
QGenericArgumentHolder
val1 –
QGenericArgumentHolder
val2 –
QGenericArgumentHolder
- Return type
object
- static PySide6.QtCore.QMetaObject.invokeMethod(object, member[, val0={}[, val1={}[, val2={}]]])
- Parameters
object –
PySide6.QtCore.QObject
member – str
val0 –
QGenericArgumentHolder
val1 –
QGenericArgumentHolder
val2 –
QGenericArgumentHolder
- Return type
bool
- static PySide6.QtCore.QMetaObject.invokeMethod(object, member, ret[, val0={}[, val1={}[, val2={}]]])
- Parameters
object –
PySide6.QtCore.QObject
member – str
ret –
QGenericReturnArgumentHolder
val0 –
QGenericArgumentHolder
val1 –
QGenericArgumentHolder
val2 –
QGenericArgumentHolder
- Return type
object
- PySide6.QtCore.QMetaObject.metaType()#
- Return type
Returns the metatype corresponding to this metaobject. If the metaobject originates from a namespace, an invalid metatype is returned.
- PySide6.QtCore.QMetaObject.method(index)#
- Parameters
index – int
- Return type
Returns the meta-data for the method with the given index
.
See also
- PySide6.QtCore.QMetaObject.methodCount()#
- Return type
int
Returns the number of methods in this class, including the number of methods provided by each base class. These include signals and slots as well as normal member functions.
Use code like the following to obtain a QStringList
containing the methods specific to a given class:
QMetaObject* metaObject = obj.metaObject() methods = QStringList() for i in range(metaObject.methodOffset(), metaObject.methodCount()): methods << QString.fromLatin1(metaObject.method(i).methodSignature())See also
- PySide6.QtCore.QMetaObject.methodOffset()#
- Return type
int
Returns the method offset for this class; i.e. the index position of this class’s first member function.
The offset is the sum of all the methods in the class’s superclasses (which is always positive since QObject
has the deleteLater() slot and a destroyed() signal).
See also
- PySide6.QtCore.QMetaObject.newInstance([val0=QGenericArgument(nullptr)[, val1=QGenericArgument()[, val2=QGenericArgument()[, val3=QGenericArgument()[, val4=QGenericArgument()[, val5=QGenericArgument()[, val6=QGenericArgument()[, val7=QGenericArgument()[, val8=QGenericArgument()[, val9=QGenericArgument()]]]]]]]]]])#
- Parameters
- Return type
Constructs a new instance of this class. You can pass up to ten arguments (val0
, val1
, val2
, val3
, val4
, val5
, val6
, val7
, val8
, and val9
) to the constructor. Returns the new object, or None
if no suitable constructor is available.
Note that only constructors that are declared with the Q_INVOKABLE
modifier are made available through the meta-object system.
See also
Q_ARG()
constructor()
- static PySide6.QtCore.QMetaObject.normalizedSignature(method)#
- Parameters
method – str
- Return type
Normalizes the signature of the given method
.
Qt uses normalized signatures to decide whether two given signals and slots are compatible. Normalization reduces whitespace to a minimum, moves ‘const’ to the front where appropriate, removes ‘const’ from value types and replaces const references with values.
See also
- static PySide6.QtCore.QMetaObject.normalizedType(type)#
- Parameters
type – str
- Return type
Normalizes a type
.
See normalizedSignature()
for a description on how Qt normalizes.
Example:
normType = QMetaObject.normalizedType(" int *") # normType is now "const int*"See also
- PySide6.QtCore.QMetaObject.property(index)#
- Parameters
index – int
- Return type
Returns the meta-data for the property with the given index
. If no such property exists, a null QMetaProperty
is returned.
- PySide6.QtCore.QMetaObject.propertyCount()#
- Return type
int
Returns the number of properties in this class, including the number of properties provided by each base class.
Use code like the following to obtain a QStringList
containing the properties specific to a given class:
QMetaObject* metaObject = obj.metaObject() properties = QStringList() for i in range(metaObject.propertyOffset(), metaObject.propertyCount()): properties << QString.fromLatin1(metaObject.property(i).name())See also
- PySide6.QtCore.QMetaObject.propertyOffset()#
- Return type
int
Returns the property offset for this class; i.e. the index position of this class’s first property.
The offset is the sum of all the properties in the class’s superclasses (which is always positive since QObject
has the name() property).
See also
- PySide6.QtCore.QMetaObject.superClass()#
- Return type
Returns the meta-object of the superclass, or None
if there is no such object.
See also
- PySide6.QtCore.QMetaObject.userProperty()#
- Return type
Returns the property that has the USER
flag set to true.
See also