diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-11-18 13:27:04 +0100 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-11-19 14:53:57 +0100 |
| commit | 943aa9ef6fef7533a3566f230aaf878efe46725e (patch) | |
| tree | 97e05257c3fd19df657ea08289d1682080bf50b7 /sources/pyside6/PySide6/glue/qtgui.cpp | |
| parent | 554d28f8f2c6104aca88079e9c7999d30eaf629a (diff) | |
PySide6: Add a sequence protocol for QRegion
Pick-to: 6.2
Fixes: PYSIDE-1714
Change-Id: I581e8088e25ab31afdfc6cd5a15c55a5b418ffdc
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/pyside6/PySide6/glue/qtgui.cpp')
| -rw-r--r-- | sources/pyside6/PySide6/glue/qtgui.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/sources/pyside6/PySide6/glue/qtgui.cpp b/sources/pyside6/PySide6/glue/qtgui.cpp index 39d5bf0ae..5630406a4 100644 --- a/sources/pyside6/PySide6/glue/qtgui.cpp +++ b/sources/pyside6/PySide6/glue/qtgui.cpp @@ -718,6 +718,20 @@ else %PYARG_0 = %CONVERTTOPYTHON[int](cppResult); // @snippet qdrag-exec-arg2 +// @snippet qregion-len +return %CPPSELF.rectCount(); +// @snippet qregion-len + +// @snippet qregion-getitem +if (_i < 0 || _i >= %CPPSELF.rectCount()) { + PyErr_SetString(PyExc_IndexError, "index out of bounds"); + return nullptr; +} + +const QRect cppResult = *(%CPPSELF.cbegin() + _i); +return %CONVERTTOPYTHON[QRect](cppResult); +// @snippet qregion-getitem + /********************************************************************* * CONVERSIONS ********************************************************************/ |
