aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/doc/tutorials
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2024-01-02 13:36:54 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2024-01-05 20:36:16 +0100
commita8fcf44147167e186a1c7da7488ab821cc041291 (patch)
tree4418db3e2035855c99965138f5e823f6633a5fa5 /sources/pyside6/doc/tutorials
parenta89ef2c8db70cb640d9a153e669847438522668d (diff)
Improve tutorial on string-based connections
Mention the use cases (most prominently DBus), give some instructions on how to obtain the signature and link it. Pick-to: 6.6 Task-number: PYSIDE-2547 Task-number: PYSIDE-2563 Change-Id: I303ef09b26a5fc2c0ab14828aa4996e2055f8b95 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Diffstat (limited to 'sources/pyside6/doc/tutorials')
-rw-r--r--sources/pyside6/doc/tutorials/basictutorial/signals_and_slots.rst23
1 files changed, 20 insertions, 3 deletions
diff --git a/sources/pyside6/doc/tutorials/basictutorial/signals_and_slots.rst b/sources/pyside6/doc/tutorials/basictutorial/signals_and_slots.rst
index 9c216da6d..e5d746c22 100644
--- a/sources/pyside6/doc/tutorials/basictutorial/signals_and_slots.rst
+++ b/sources/pyside6/doc/tutorials/basictutorial/signals_and_slots.rst
@@ -139,6 +139,9 @@ useful for QML applications to refer to the emitted values by name:
// do something with 'sum'
}
+
+.. _slot-decorator:
+
The Slot Class
--------------
@@ -223,6 +226,8 @@ the different functionality.
someone.speak[str].emit("Hello everybody!")
+.. _signals-and-slots-strings:
+
Specifying Signals and Slots by Method Signature Strings
--------------------------------------------------------
@@ -235,12 +240,24 @@ strings passed through the ``SIGNAL()`` and/or ``SLOT()`` functions:
from PySide6.QtCore import SIGNAL, SLOT
button.connect(SIGNAL("clicked(Qt::MouseButton)"),
- action_handler, SLOT("action1(Qt::MouseButton)"))
+ action_handler, SLOT("action1(Qt::MouseButton)"))
-This is not recommended for connecting signals, it is mostly
-used to specify signals for methods like ``QWizardPage::registerField()``:
+This is not normally recommended; it is only needed
+for a few cases where signals are only accessible via ``QMetaObject``
+(``QAxObject``, ``QAxWidget``, ``QDBusInterface`` or ``QWizardPage::registerField()``):
.. code-block:: python
wizard.registerField("text", line_edit, "text",
SIGNAL("textChanged(QString)"))
+
+The signature strings can be found by querying ``QMetaMethod.methodSignature()``
+when introspecting ``QMetaObject``:
+
+.. code-block:: python
+
+ mo = widget.metaObject()
+ for m in range(mo.methodOffset(), mo.methodCount()):
+ print(mo.method(m).methodSignature())
+
+Slots should be decorated using :ref:`@Slot <slot-decorator>`.