From 29bdff9f1466ea46f0a4bd6205c5e39d000666a5 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 21 Jan 2022 17:11:18 +0100 Subject: PySide6: Add __repr__ to QEvents Add a basic __repr__ function to QEvent that shows the type enumeration value. For QtGui, use the debug operator from qevent.h for the relevant events. Add a generic template for using QDebug with module name. [ChangeLog][PySide6] __repr__ functions for some QEvent-derived classes were added. Task-number: PYSIDE-1788 Change-Id: I02aca4c98cf3ebd69558103c7d23660d1eb840fb Reviewed-by: Cristian Maureira-Fredes (cherry picked from commit 3706622525261e10c4f8eaeecd977de7e455b8f5) Reviewed-by: Qt Cherry-pick Bot --- .../PySide6/QtCore/typesystem_core_common.xml | 4 + .../PySide6/QtGui/typesystem_gui_common.xml | 108 ++++++++++++++++++--- sources/pyside6/PySide6/glue/qtcore.cpp | 6 ++ sources/pyside6/PySide6/templates/core_common.xml | 12 +++ 4 files changed, 119 insertions(+), 11 deletions(-) diff --git a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml index 4e9a1c55a..f00d01680 100644 --- a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml +++ b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml @@ -2562,6 +2562,10 @@ + + + diff --git a/sources/pyside6/PySide6/QtGui/typesystem_gui_common.xml b/sources/pyside6/PySide6/QtGui/typesystem_gui_common.xml index caecca7bf..6c3c97c0f 100644 --- a/sources/pyside6/PySide6/QtGui/typesystem_gui_common.xml +++ b/sources/pyside6/PySide6/QtGui/typesystem_gui_common.xml @@ -1390,20 +1390,49 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + @@ -1415,35 +1444,75 @@ + + + + + - + + + + + + + - + + + + + + + - + + + + + + + - + + + + + + + - + + + + + + + + + + + + @@ -1456,12 +1525,23 @@ + + + + + - + + + + + + + @@ -2366,7 +2446,13 @@ - + + + + + + + diff --git a/sources/pyside6/PySide6/glue/qtcore.cpp b/sources/pyside6/PySide6/glue/qtcore.cpp index da2e016ea..251c660a0 100644 --- a/sources/pyside6/PySide6/glue/qtcore.cpp +++ b/sources/pyside6/PySide6/glue/qtcore.cpp @@ -1995,3 +1995,9 @@ Py_INCREF(callable); %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(cppCallback); %PYARG_0 = %CONVERTTOPYTHON[int](cppResult); // @snippet qthreadpool-trystart + +// @snippet repr-qevent +QString result; +QDebug(&result).nospace() << "type() << ")>"; +%PYARG_0 = Shiboken::String::fromCString(qPrintable(result)); +// @snippet repr-qevent diff --git a/sources/pyside6/PySide6/templates/core_common.xml b/sources/pyside6/PySide6/templates/core_common.xml index abc0d6425..044122457 100644 --- a/sources/pyside6/PySide6/templates/core_common.xml +++ b/sources/pyside6/PySide6/templates/core_common.xml @@ -249,6 +249,18 @@ %PYARG_0 = Shiboken::String::fromCString(qPrintable(format)); + + + +