Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QPolygonF Class Reference

The QPolygonF class provides a list of points using floating point precision. More...

#include <qpolygon.h>

+ Inheritance diagram for QPolygonF:
+ Collaboration diagram for QPolygonF:

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
 
- Public Member Functions inherited from QList< QPointF >
 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 (qsizetype size, Qt::Initialization)
 
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)
 
void resizeForOverwrite (qsizetype size)
 
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)
 
QListassign (qsizetype n, parameter_type t)
 
QListassign (InputIterator first, InputIterator last)
 
QListassign (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)
 
QPointFfirst ()
 
const QPointFfirst () const noexcept
 
QList< QPointFfirst (qsizetype n) const
 
const QPointFconstFirst () const noexcept
 
QPointFlast ()
 
const QPointFlast () const noexcept
 
QList< QPointFlast (qsizetype n) const
 
const QPointFconstLast () const noexcept
 
bool startsWith (parameter_type t) const
 
bool endsWith (parameter_type t) const
 
QList< QPointFmid (qsizetype pos, qsizetype len=-1) const
 
QList< QPointFsliced (qsizetype pos) const
 
QList< QPointFsliced (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< QPointFoperator+ (const QList< QPointF > &l) const &
 
QList< QPointFoperator+ (const QList< QPointF > &l) &&
 
QList< QPointFoperator+ (QList< QPointF > &&l) const &
 
QList< QPointFoperator+ (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< QPointFtoList () const noexcept
 
QList< QPointFtoVector () const noexcept
 
- Public Member Functions inherited from QListSpecialMethodsBase< T >
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.)

QDataStreamoperator<< (QDataStream &stream, const QPolygonF &polygon)
 Writes the given polygon to the given stream, and returns a reference to the stream.
 
QDataStreamoperator>> (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

- Public Types inherited from QList< QPointF >
using Type
 
using value_type
 
using pointer
 
using const_pointer
 
using reference
 
using const_reference
 
using size_type
 
using difference_type
 
using parameter_type
 
using rvalue_ref
 
using Iterator
 
using ConstIterator
 
using reverse_iterator
 
using const_reverse_iterator
 
- Static Public Member Functions inherited from QList< QPointF >
static qsizetype max_size () noexcept
 
static QList< QPointFfromList (const QList< QPointF > &list) noexcept
 
static QList< QPointFfromVector (const QList< QPointF > &vector) noexcept
 
static QList< QPointFfromReadOnlyData (const QPointF(&t)[N]) noexcept
 
- Protected Types inherited from QListSpecialMethodsBase< T >
using Self = QList<T>
 
- Protected Member Functions inherited from QListSpecialMethods< T >
 ~QListSpecialMethods ()=default
 
- Protected Member Functions inherited from QListSpecialMethodsBase< T >
 ~QListSpecialMethodsBase ()=default
 
Selfself ()
 
const Selfself () const
 

Detailed Description

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:

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

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}.

See also
QList, QPolygon, QLineF

Definition at line 95 of file qpolygon.h.

Constructor & Destructor Documentation

◆ QPolygonF() [1/5]

QPolygonF::QPolygonF ( )
default

Constructs a polygon with no points.

See also
QList::isEmpty()

◆ QPolygonF() [2/5]

QPolygonF::QPolygonF ( const QList< QPointF > & v)
inline

Constructs a polygon containing the specified points.

Definition at line 100 of file qpolygon.h.

◆ QPolygonF() [3/5]

Q_IMPLICIT QPolygonF::QPolygonF ( QList< QPointF > && v)
inlinenoexcept

Definition at line 101 of file qpolygon.h.

◆ QPolygonF() [4/5]

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.

See also
isClosed()

Definition at line 489 of file qpolygon.cpp.

References QList< QPointF >::append(), and QList< QPointF >::reserve().

+ Here is the call graph for this function:

◆ QPolygonF() [5/5]

QPolygonF::QPolygonF ( const QPolygon & polygon)

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

See also
toPolygon()

Definition at line 508 of file qpolygon.cpp.

References QList< QPointF >::append(), i, and QList< QPointF >::reserve().

+ Here is the call graph for this function:

Member Function Documentation

◆ boundingRect()

QRectF QPolygonF::boundingRect ( ) const

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

See also
QList::isEmpty()

Definition at line 583 of file qpolygon.cpp.

References QList< QPointF >::constData(), QList< QPointF >::size(), QPointF::x(), and QPointF::y().

Referenced by QSvgPolygon::fastBounds(), QSvgPolyline::fastBounds(), and QGraphicsPolygonItem::setPolygon().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ containsPoint()

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

Returns true if the given point is inside the polygon according to the specified fillRule; otherwise returns false.

Definition at line 735 of file qpolygon.cpp.

References at, i, QList< QPointF >::isEmpty(), qt_polygon_isect_line(), QList< QPointF >::size(), and Qt::WindingFill.

+ Here is the call graph for this function:

◆ intersected()

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

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.

See also
intersects()

Definition at line 896 of file qpolygon.cpp.

References QPainterPath::addPolygon(), QPainterPath::intersected(), and QPainterPath::toFillPolygon().

+ Here is the call graph for this function:

◆ intersects()

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

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.

See also
intersected()

Definition at line 933 of file qpolygon.cpp.

References QPainterPath::addPolygon(), and QPainterPath::intersects().

+ Here is the call graph for this function:

◆ isClosed()

bool QPolygonF::isClosed ( ) const
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.

See also
QList::first(), QList::last()

Definition at line 116 of file qpolygon.h.

References QList< QPointF >::first(), QList< QPointF >::isEmpty(), and QList< QPointF >::last().

+ Here is the call graph for this function:

◆ operator QVariant()

QPolygonF::operator QVariant ( ) const

Returns the polygon as a QVariant.

Definition at line 945 of file qpolygon.cpp.

References QVariant::fromValue().

+ Here is the call graph for this function:

◆ subtracted()

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

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 914 of file qpolygon.cpp.

References QPainterPath::addPolygon(), QPainterPath::subtracted(), and QPainterPath::toFillPolygon().

+ Here is the call graph for this function:

◆ swap()

void QPolygonF::swap ( QPolygonF & other)
inline
Since
4.8

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().

+ Here is the call graph for this function:

◆ toPolygon()

QPolygon QPolygonF::toPolygon ( ) const

Creates and returns a QPolygon by converting each QPointF to a QPoint.

See also
QPointF::toPoint()

Definition at line 614 of file qpolygon.cpp.

References at, i, QList< T >::reserve(), and QList< QPointF >::size().

Referenced by QPolygon::intersected(), QPolygon::subtracted(), and QPolygon::united().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ translate() [1/2]

void QPolygonF::translate ( const QPointF & offset)

Translate all points in the polygon by the given offset.

See also
translated()

Definition at line 521 of file qpolygon.cpp.

References QList< QPointF >::data(), i, and QList< QPointF >::size().

+ Here is the call graph for this function:

◆ translate() [2/2]

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

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}).

See also
translated()

Definition at line 144 of file qpolygon.h.

References translate().

Referenced by translate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ translated() [1/2]

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

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

Since
4.6
See also
translate()

Definition at line 549 of file qpolygon.cpp.

References copy().

+ Here is the call graph for this function:

◆ translated() [2/2]

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

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
4.6

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

See also
translate()

Definition at line 147 of file qpolygon.h.

References translated().

Referenced by translated().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ united()

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

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.

See also
intersected(), subtracted()

Definition at line 877 of file qpolygon.cpp.

References QPainterPath::addPolygon(), QPainterPath::toFillPolygon(), and QPainterPath::united().

+ Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ operator<<()

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

Writes the given polygon to the given stream, and returns a reference to the stream.

See also
{Serializing Qt Data Types}

Definition at line 698 of file qpolygon.cpp.

◆ operator>>()

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

Reads a polygon from the given stream into the given polygon, and returns a reference to the stream.

See also
{Serializing Qt Data Types}

Definition at line 713 of file qpolygon.cpp.


The documentation for this class was generated from the following files: