Skip to content

Commit 5603546

Browse files
committed
Dox
1 parent e21ea25 commit 5603546

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

python/core/auto_generated/qgsfeature.sip.in

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,24 @@ Set the feature's geometry. The feature will be valid after.
333333
Set the feature's ``geometry``. Ownership of the geometry is transferred to the feature.
334334
The feature will be made valid after calling this method.
335335

336+
This method is a shortcut for calling:
337+
.. code-block:: python
338+
339+
feature.setGeometry( QgsGeometry( geometry ) )
340+
341+
* Example:
342+
.. code-block:: python
343+
344+
# Sets a feature's geometry to a point geometry
345+
feature.setGeometry( QgsPoint( 210, 41 ) )
346+
print(feature.geometry())
347+
# output: <QgsGeometry: Point (210 41)>
348+
349+
# Sets a feature's geometry to a line string
350+
feature.setGeometry( QgsLineString( [ QgsPoint( 210, 41 ), QgsPoint( 301, 55 ) ] ) )
351+
print(feature.geometry())
352+
# output: <QgsGeometry: LineString (210 41, 301 55)>
353+
336354
.. seealso:: :py:func:`geometry`
337355

338356
.. seealso:: :py:func:`clearGeometry`

src/core/qgsfeature.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,25 @@ class CORE_EXPORT QgsFeature
349349
/**
350350
* Set the feature's \a geometry. Ownership of the geometry is transferred to the feature.
351351
* The feature will be made valid after calling this method.
352+
*
353+
* This method is a shortcut for calling:
354+
* \code{.py}
355+
* feature.setGeometry( QgsGeometry( geometry ) )
356+
* \endcode
357+
*
358+
* * Example:
359+
* \code{.py}
360+
* # Sets a feature's geometry to a point geometry
361+
* feature.setGeometry( QgsPoint( 210, 41 ) )
362+
* print(feature.geometry())
363+
* # output: <QgsGeometry: Point (210 41)>
364+
*
365+
* # Sets a feature's geometry to a line string
366+
* feature.setGeometry( QgsLineString( [ QgsPoint( 210, 41 ), QgsPoint( 301, 55 ) ] ) )
367+
* print(feature.geometry())
368+
* # output: <QgsGeometry: LineString (210 41, 301 55)>
369+
* \endcode
370+
*
352371
* \see geometry()
353372
* \see clearGeometry()
354373
* \since QGIS 3.6

0 commit comments

Comments
 (0)