From 247c14cf39f61365f9cadd5efdd36d42616e0b60 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 25 Aug 2023 14:10:02 +0200 Subject: Documentation/Signal slot tutorial: Recommend to use @Slot always Task-number: PYSIDE-463 Task-number: PYSIDE-2436 Change-Id: Ida83a0b4207ab499cfaaa2090f8aabbc6246bff5 Reviewed-by: Cristian Maureira-Fredes (cherry picked from commit f762506f956e06514a3188fc6dab0846c94496e6) Reviewed-by: Qt Cherry-pick Bot --- .../doc/tutorials/basictutorial/signals_and_slots.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sources/pyside6/doc/tutorials/basictutorial/signals_and_slots.rst b/sources/pyside6/doc/tutorials/basictutorial/signals_and_slots.rst index d02a6d9ff..702882ffb 100644 --- a/sources/pyside6/doc/tutorials/basictutorial/signals_and_slots.rst +++ b/sources/pyside6/doc/tutorials/basictutorial/signals_and_slots.rst @@ -159,6 +159,19 @@ Python type. The ``name`` keyword behaves the same way as in ``Signal()``. If nothing is passed as name then the new slot will have the same name as the function that is being decorated. +We recommend marking all methods used by signal connections with a +``@QtCore.Slot()`` decorator. Not doing causes run-time overhead due to the +method being added to the ``QMetaObject`` when creating the connection. This is +particularly important for ``QObject`` classes registered with QML, where +missing decorators can introduce bugs. + +Missing decorators can be diagnosed by setting activating warnings of the +logging category ``qt.pyside.libpyside``; for example by setting the +environment variable: + +.. code-block:: bash + + export QT_LOGGING_RULES="qt.pyside.libpyside.warning=true" .. _overloading-signals-and-slots: -- cgit v1.2.3