![]() |
Qt 6.x
The Qt SDK
|
The QPolygonF class provides a list of points using floating point precision. More...
#include <qpolygon.h>
Public Member Functions | |
QPolygonF ()=default | |
Constructs a polygon with no points. | |
Q_IMPLICIT | QPolygonF (const QList< QPointF > &v) |
Constructs a polygon containing the specified points. | |
Q_IMPLICIT | QPolygonF (QList< QPointF > &&v) noexcept |
Q_IMPLICIT Q_GUI_EXPORT | QPolygonF (const QRectF &r) |
Constructs a closed polygon from the specified rectangle. | |
Q_IMPLICIT Q_GUI_EXPORT | QPolygonF (const QPolygon &a) |
Constructs a float based polygon from the specified integer based polygon. | |
void | swap (QPolygonF &other) |
Q_GUI_EXPORT | operator QVariant () const |
Returns the polygon as a QVariant. | |
void | translate (qreal dx, qreal dy) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Translates all points in the polygon by ({dx}, {dy}). | |
void Q_GUI_EXPORT | translate (const QPointF &offset) |
Translate all points in the polygon by the given offset. | |
QPolygonF | translated (qreal dx, qreal dy) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
Q_GUI_EXPORT QPolygonF | translated (const QPointF &offset) const |
Returns a copy of the polygon that is translated by the given offset. | |
QPolygon Q_GUI_EXPORT | toPolygon () const |
Creates and returns a QPolygon by converting each QPointF to a QPoint. | |
bool | isClosed () const |
Returns true if the polygon is closed; otherwise returns false . | |
QRectF Q_GUI_EXPORT | boundingRect () const |
Returns the bounding rectangle of the polygon, or QRectF(0,0,0,0) if the polygon is empty. | |
Q_GUI_EXPORT bool | containsPoint (const QPointF &pt, Qt::FillRule fillRule) const |
Q_GUI_EXPORT QPolygonF | united (const QPolygonF &r) const |
Q_GUI_EXPORT QPolygonF | intersected (const QPolygonF &r) const |
Q_GUI_EXPORT QPolygonF | subtracted (const QPolygonF &r) const |
Q_GUI_EXPORT bool | intersects (const QPolygonF &r) const |
![]() | |
QList (DataPointer dd) noexcept | |
QList ()=default | |
QList (qsizetype size) | |
QList (qsizetype size, parameter_type t) | |
QList (std::initializer_list< QPointF > args) | |
QList (InputIterator i1, InputIterator i2) | |
QList (const String &str) | |
QList< QPointF > & | operator= (std::initializer_list< QPointF > args) |
void | swap (QList &other) noexcept |
QTypeTraits::compare_eq_result_container< QList, U > | operator== (const QList &other) const |
QTypeTraits::compare_eq_result_container< QList, U > | operator!= (const QList &other) const |
QTypeTraits::compare_lt_result_container< QList, U > | operator< (const QList &other) const noexcept(noexcept(std::lexicographical_compare< typename QList< U >::const_iterator, typename QList::const_iterator >(std::declval< QList< U > >().begin(), std::declval< QList< U > >().end(), other.begin(), other.end()))) |
QTypeTraits::compare_lt_result_container< QList, U > | operator> (const QList &other) const noexcept(noexcept(other< std::declval< QList< U > >())) |
QTypeTraits::compare_lt_result_container< QList, U > | operator<= (const QList &other) const noexcept(noexcept(other< std::declval< QList< U > >())) |
QTypeTraits::compare_lt_result_container< QList, U > | operator>= (const QList &other) const noexcept(noexcept(std::declval< QList< U > >()< other)) |
qsizetype | size () const noexcept |
qsizetype | count () const noexcept |
qsizetype | count (const AT &t) const noexcept |
qsizetype | length () const noexcept |
bool | isEmpty () const noexcept |
void | resize (qsizetype size) |
void | resize (qsizetype size, parameter_type c) |
qsizetype | capacity () const |
void | reserve (qsizetype size) |
void | squeeze () |
void | detach () |
bool | isDetached () const noexcept |
bool | isSharedWith (const QList< QPointF > &other) const |
pointer | data () |
const_pointer | data () const noexcept |
const_pointer | constData () const noexcept |
void | clear () |
const_reference | at (qsizetype i) const noexcept |
reference | operator[] (qsizetype i) |
const_reference | operator[] (qsizetype i) const noexcept |
void | append (parameter_type t) |
void | append (const_iterator i1, const_iterator i2) |
void | append (rvalue_ref t) |
void | append (const QList< QPointF > &l) |
void | append (QList< QPointF > &&l) |
void | prepend (rvalue_ref t) |
void | prepend (parameter_type t) |
reference | emplaceBack (Args &&... args) |
reference | emplaceFront (Args &&... args) |
iterator | insert (qsizetype i, parameter_type t) |
iterator | insert (qsizetype i, qsizetype n, parameter_type t) |
iterator | insert (const_iterator before, parameter_type t) |
iterator | insert (const_iterator before, qsizetype n, parameter_type t) |
iterator | insert (const_iterator before, rvalue_ref t) |
iterator | insert (qsizetype i, rvalue_ref t) |
QList & | assign (qsizetype n, parameter_type t) |
QList & | assign (InputIterator first, InputIterator last) |
QList & | assign (std::initializer_list< QPointF > l) |
iterator | emplace (const_iterator before, Args &&... args) |
iterator | emplace (qsizetype i, Args &&... args) |
void | replace (qsizetype i, parameter_type t) |
void | replace (qsizetype i, rvalue_ref t) |
void | remove (qsizetype i, qsizetype n=1) |
void | removeFirst () noexcept |
void | removeLast () noexcept |
value_type | takeFirst () |
value_type | takeLast () |
QList< QPointF > & | fill (parameter_type t, qsizetype size=-1) |
void | removeAt (qsizetype i) |
qsizetype | removeAll (const AT &t) |
bool | removeOne (const AT &t) |
qsizetype | removeIf (Predicate pred) |
QPointF | takeAt (qsizetype i) |
void | move (qsizetype from, qsizetype to) |
iterator | begin () |
const_iterator | begin () const noexcept |
iterator | end () |
const_iterator | end () const noexcept |
const_iterator | cbegin () const noexcept |
const_iterator | cend () const noexcept |
const_iterator | constBegin () const noexcept |
const_iterator | constEnd () const noexcept |
reverse_iterator | rbegin () |
const_reverse_iterator | rbegin () const noexcept |
reverse_iterator | rend () |
const_reverse_iterator | rend () const noexcept |
const_reverse_iterator | crbegin () const noexcept |
const_reverse_iterator | crend () const noexcept |
iterator | erase (const_iterator begin, const_iterator end) |
iterator | erase (const_iterator pos) |
QPointF & | first () |
const QPointF & | first () const noexcept |
QList< QPointF > | first (qsizetype n) const |
const QPointF & | constFirst () const noexcept |
QPointF & | last () |
const QPointF & | last () const noexcept |
QList< QPointF > | last (qsizetype n) const |
const QPointF & | constLast () const noexcept |
bool | startsWith (parameter_type t) const |
bool | endsWith (parameter_type t) const |
QList< QPointF > | mid (qsizetype pos, qsizetype len=-1) const |
QList< QPointF > | sliced (qsizetype pos) const |
QList< QPointF > | sliced (qsizetype pos, qsizetype n) const |
QPointF | value (qsizetype i) const |
QPointF | value (qsizetype i, parameter_type defaultValue) const |
void | swapItemsAt (qsizetype i, qsizetype j) |
void | push_back (parameter_type t) |
void | push_back (rvalue_ref t) |
void | push_front (rvalue_ref t) |
void | push_front (parameter_type t) |
void | pop_back () noexcept |
void | pop_front () noexcept |
reference | emplace_back (Args &&... args) |
bool | empty () const noexcept |
reference | front () |
const_reference | front () const noexcept |
reference | back () |
const_reference | back () const noexcept |
void | shrink_to_fit () |
QList< QPointF > & | operator+= (const QList< QPointF > &l) |
QList< QPointF > & | operator+= (QList< QPointF > &&l) |
QList< QPointF > & | operator+= (parameter_type t) |
QList< QPointF > & | operator+= (rvalue_ref t) |
QList< QPointF > | operator+ (const QList< QPointF > &l) const & |
QList< QPointF > | operator+ (const QList< QPointF > &l) && |
QList< QPointF > | operator+ (QList< QPointF > &&l) const & |
QList< QPointF > | operator+ (QList< QPointF > &&l) && |
QList< QPointF > & | operator<< (parameter_type t) |
QList< QPointF > & | operator<< (const QList< QPointF > &l) |
QList< QPointF > & | operator<< (QList< QPointF > &&l) |
QList< QPointF > & | operator<< (rvalue_ref t) |
QList< QPointF > | toList () const noexcept |
QList< QPointF > | toVector () const noexcept |
![]() | |
template<typename AT = T> | |
qsizetype | indexOf (const AT &t, qsizetype from=0) const noexcept |
template<typename AT = T> | |
qsizetype | lastIndexOf (const AT &t, qsizetype from=-1) const noexcept |
template<typename AT = T> | |
bool | contains (const AT &t) const noexcept |
Related Symbols | |
(Note that these are not member symbols.) | |
QDataStream & | operator<< (QDataStream &stream, const QPolygonF &polygon) |
Writes the given polygon to the given stream, and returns a reference to the stream. | |
QDataStream & | operator>> (QDataStream &stream, QPolygonF &polygon) |
Reads a polygon from the given stream into the given polygon, and returns a reference to the stream. | |
Additional Inherited Members | |
![]() | |
using | Type = QPointF |
using | value_type = QPointF |
using | pointer = QPointF * |
using | const_pointer = const QPointF * |
using | reference = QPointF & |
using | const_reference = const QPointF & |
using | size_type = qsizetype |
using | difference_type = qptrdiff |
using | parameter_type = typename DataPointer::parameter_type |
using | rvalue_ref = typename std::conditional< DataPointer::pass_parameter_by_value, DisableRValueRefs, QPointF && >::type |
using | Iterator = iterator |
using | ConstIterator = const_iterator |
using | reverse_iterator = std::reverse_iterator< iterator > |
using | const_reverse_iterator = std::reverse_iterator< const_iterator > |
![]() | |
static QList< QPointF > | fromList (const QList< QPointF > &list) noexcept |
static QList< QPointF > | fromVector (const QList< QPointF > &vector) noexcept |
static QList< QPointF > | fromReadOnlyData (const QPointF(&t)[N]) noexcept |
![]() | |
using | Self = QList< T > |
![]() | |
~QListSpecialMethods ()=default | |
![]() | |
~QListSpecialMethodsBase ()=default | |
Self * | self () |
const Self * | self () const |
The QPolygonF class provides a list of points using floating point precision.
\inmodule QtGui
\reentrant
A QPolygonF is a QList<QPointF>. The easiest way to add points to a QPolygonF is to use its streaming operator, as illustrated below:
In addition to the functions provided by QList, QPolygonF provides the boundingRect() and 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 \l {Implicit Data Sharing}{implicitly shared}.
Definition at line 95 of file qpolygon.h.
|
default |
Constructs a polygon with no points.
Constructs a polygon containing the specified points.
Definition at line 100 of file qpolygon.h.
|
inlinenoexcept |
Definition at line 101 of file qpolygon.h.
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.
Definition at line 494 of file qpolygon.cpp.
References QList< QPointF >::append(), and QList< QPointF >::reserve().
QPolygonF::QPolygonF | ( | const QPolygon & | polygon | ) |
Constructs a float based polygon from the specified integer based polygon.
Definition at line 513 of file qpolygon.cpp.
References QList< QPointF >::append(), i, and QList< QPointF >::reserve().
QRectF QPolygonF::boundingRect | ( | ) | const |
Returns the bounding rectangle of the polygon, or QRectF(0,0,0,0) if the polygon is empty.
Definition at line 588 of file qpolygon.cpp.
References QList< QPointF >::constData(), QList< QPointF >::size(), QPointF::x(), and QPointF::y().
Referenced by QSvgPolygon::fastBounds(), QSvgPolyline::fastBounds(), QGraphicsViewPrivate::mapToScene(), QGraphicsView::render(), and QQuickPdfSelection::selectAll().
bool QPolygonF::containsPoint | ( | const QPointF & | point, |
Qt::FillRule | fillRule | ||
) | const |
Returns true
if the given point is inside the polygon according to the specified fillRule; otherwise returns false
.
Definition at line 761 of file qpolygon.cpp.
References at, e, i, QList< QPointF >::isEmpty(), qt_polygon_isect_line(), QList< QPointF >::size(), and Qt::WindingFill.
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.
Definition at line 922 of file qpolygon.cpp.
References QPainterPath::addPolygon(), QPainterPath::intersected(), and QPainterPath::toFillPolygon().
bool QPolygonF::intersects | ( | const QPolygonF & | p | ) | const |
Returns true
if the current polygon intersects at any point the given polygon p. Also returns 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.
Definition at line 959 of file qpolygon.cpp.
References QPainterPath::addPolygon(), and QPainterPath::intersects().
|
inline |
Returns 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.
Definition at line 116 of file qpolygon.h.
References QList< QPointF >::first(), QList< QPointF >::isEmpty(), and QList< QPointF >::last().
Referenced by QPainterPath::toFillPolygons().
QPolygonF::operator QVariant | ( | ) | const |
Returns the polygon as a QVariant.
Definition at line 971 of file qpolygon.cpp.
References QVariant::fromValue().
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.
Definition at line 940 of file qpolygon.cpp.
References QPainterPath::addPolygon(), QPainterPath::subtracted(), and QPainterPath::toFillPolygon().
Swaps polygon other with this polygon. This operation is very fast and never fails.
Definition at line 104 of file qpolygon.h.
References other(), and QList< T >::swap().
QPolygon QPolygonF::toPolygon | ( | ) | const |
Creates and returns a QPolygon by converting each QPointF to a QPoint.
Definition at line 619 of file qpolygon.cpp.
References at, i, and QList< QPointF >::size().
Referenced by QPolygon::intersected(), QTransform::map(), QPolygon::subtracted(), QX11PaintEnginePrivate::systemStateChanged(), QPolygon::united(), and QX11PaintEngine::updateState().
Translate all points in the polygon by the given offset.
Definition at line 526 of file qpolygon.cpp.
References QList< QPointF >::data(), i, and QList< QPointF >::size().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Translates all points in the polygon by ({dx}, {dy}).
Definition at line 144 of file qpolygon.h.
References translate().
Referenced by translate().
Returns a copy of the polygon that is translated by the given offset.
Definition at line 554 of file qpolygon.cpp.
References copy().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Returns a copy of the polygon that is translated by ({dx}, {dy}).
Definition at line 147 of file qpolygon.h.
References translated().
Referenced by translated().
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.
Definition at line 903 of file qpolygon.cpp.
References QPainterPath::addPolygon(), QPainterPath::toFillPolygon(), and QPainterPath::united().
|
related |
Writes the given polygon to the given stream, and returns a reference to the stream.
Definition at line 703 of file qpolygon.cpp.
References i.
|
related |
Reads a polygon from the given stream into the given polygon, and returns a reference to the stream.
Definition at line 724 of file qpolygon.cpp.
References i.