QPolygonF 類

QPolygonF 類提供使用浮點精度的點列錶。 更多...

頭: #include <QPolygonF>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
繼承: QList

注意: 此類的所有函數 可重入 .

公共函數

QPolygonF ()
QPolygonF (const QList<QPointF> & points )
QPolygonF (const QPolygon & polygon )
QPolygonF (const QRectF & rectangle )
QRectF boundingRect () const
bool containsPoint (const QPointF & point , Qt::FillRule fillRule ) const
QPolygonF intersected (const QPolygonF & r ) const
bool intersects (const QPolygonF & p ) const
bool isClosed () const
QPolygonF subtracted (const QPolygonF & r ) const
void swap (QPolygonF & other )
QPolygon toPolygon () const
void translate (const QPointF & offset )
void translate (qreal dx , qreal dy )
QPolygonF translated (const QPointF & offset ) const
QPolygonF translated (qreal dx , qreal dy ) const
QPolygonF united (const QPolygonF & r ) const
QVariant operator QVariant () const
QDataStream & operator<< (QDataStream & stream , const QPolygonF & polygon )
QDataStream & operator>> (QDataStream & stream , QPolygonF & polygon )

詳細描述

A QPolygonF is a QList < QPointF >. The easiest way to add points to a QPolygonF is to use its streaming operator, as illustrated below:

QPolygonF polygon;
polygon << QPointF(10.4, 20.5) << QPointF(20.2, 30.2);
					

In addition to the functions provided by QList , QPolygonF provides the boundingRect () 和 translate () functions for geometry operations. Use the QTransform::map () function for more general transformations of QPolygonFs.

QPolygonF also provides the isClosed () function to determine whether a polygon's start and end points are the same, and the toPolygon () function returning an integer precision copy of this polygon.

The QPolygonF class is 隱式共享 .

另請參閱 QList , QPolygon ,和 QLineF .

成員函數文檔編製

[constexpr noexcept] QPolygonF:: QPolygonF ()

Constructs a polygon with no points.

另請參閱 QList::isEmpty ().

QPolygonF:: QPolygonF (const QList < QPointF > & points )

Constructs a polygon containing the specified points .

QPolygonF:: QPolygonF (const QPolygon & polygon )

Constructs a float based polygon from the specified integer based polygon .

另請參閱 toPolygon ().

QPolygonF:: QPolygonF (const QRectF & rectangle )

Constructs a closed polygon from the specified rectangle .

The polygon contains the four vertices of the rectangle in clockwise order starting and ending with the top-left vertex.

另請參閱 isClosed ().

QRectF QPolygonF:: boundingRect () const

Returns the bounding rectangle of the polygon, or QRectF (0,0,0,0) if the polygon is empty.

另請參閱 QList::isEmpty ().

bool QPolygonF:: containsPoint (const QPointF & point , Qt::FillRule fillRule ) const

返迴 true 若給定 point is inside the polygon according to the specified fillRule ;否則返迴 false .

QPolygonF QPolygonF:: intersected (const QPolygonF & r ) const

Returns a polygon which is the intersection of this polygon and r .

Set operations on polygons will treat the polygons as areas. Non-closed polygons will be treated as implicitly closed.

另請參閱 intersects ().

bool QPolygonF:: intersects (const QPolygonF & p ) const

返迴 true if the current polygon intersects at any point the given polygon p 。也返迴 true if the current polygon contains or is contained by any part of p .

Set operations on polygons will treat the polygons as areas. Non-closed polygons will be treated as implicitly closed.

另請參閱 intersected ().

bool QPolygonF:: isClosed () const

返迴 true if the polygon is closed; otherwise returns false .

A polygon is said to be closed if its start point and end point are equal.

另請參閱 QList::first () 和 QList::last ().

QPolygonF QPolygonF:: subtracted (const QPolygonF & r ) const

Returns a polygon which is r subtracted from this polygon.

Set operations on polygons will treat the polygons as areas. Non-closed polygons will be treated as implicitly closed.

void QPolygonF:: swap ( QPolygonF & other )

Swaps this polygon with other 。此操作很快且從不失敗。

QPolygon QPolygonF:: toPolygon () const

創建並返迴 QPolygon by converting each QPointF QPoint .

另請參閱 QPointF::toPoint ().

void QPolygonF:: translate (const QPointF & offset )

Translate all points in the polygon by the given offset .

另請參閱 translated ().

void QPolygonF:: translate ( qreal dx , qreal dy )

Translates all points in the polygon by ( dx , dy ).

這是重載函數。

另請參閱 translated ().

QPolygonF QPolygonF:: translated (const QPointF & offset ) const

Returns a copy of the polygon that is translated by the given offset .

另請參閱 translate ().

QPolygonF QPolygonF:: translated ( qreal dx , qreal dy ) const

Returns a copy of the polygon that is translated by ( dx , dy ).

這是重載函數。

另請參閱 translate ().

QPolygonF QPolygonF:: united (const QPolygonF & r ) const

Returns a polygon which is the union of this polygon and r .

Set operations on polygons will treat the polygons as areas. Non-closed polygons will be treated as implicitly closed.

另請參閱 intersected () 和 subtracted ().

QVariant QPolygonF:: operator QVariant () const

Returns the polygon as a QVariant .

相關非成員

QDataStream & operator<< ( QDataStream & stream , const QPolygonF & polygon )

寫入給定 polygon 到給定 stream ,並返迴流引用。

另請參閱 序列化 Qt 數據類型 .

QDataStream & operator>> ( QDataStream & stream , QPolygonF & polygon )

Reads a polygon from the given stream 進給定 polygon ,並返迴流引用。

另請參閱 序列化 Qt 數據類型 .