QtBase  v6.3.1
Public Member Functions | Related Functions | List of all members
QPolygonF Class Reference

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

#include <qpolygon.h>

Inheritance diagram for QPolygonF:
Inheritance graph
[legend]
Collaboration diagram for QPolygonF:
Collaboration graph
[legend]

Public Member Functions

 QPolygonF ()=default
 
Q_IMPLICIT QPolygonF (const QList< QPointF > &v)
 
Q_IMPLICIT QPolygonF (QList< QPointF > &&v) noexcept
 
Q_IMPLICIT Q_GUI_EXPORT QPolygonF (const QRectF &r)
 
Q_IMPLICIT Q_GUI_EXPORT QPolygonF (const QPolygon &a)
 
void swap (QPolygonF &other)
 
Q_GUI_EXPORT operator QVariant () const
 
void translate (qreal dx, qreal dy)
 
void Q_GUI_EXPORT translate (const QPointF &offset)
 
QPolygonF translated (qreal dx, qreal dy) const
 
Q_GUI_EXPORT QPolygonF translated (const QPointF &offset) const
 
QPolygon Q_GUI_EXPORT toPolygon () const
 
bool isClosed () const
 
QRectF Q_GUI_EXPORT boundingRect () const
 
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< QPointF > & operator= (std::initializer_list< QPointF > args)
 
void swap (QList &other) noexcept
 
QTypeTraits::compare_eq_result_container< QList, Uoperator== (const QList &other) const
 
QTypeTraits::compare_eq_result_container< QList, Uoperator!= (const QList &other) const
 
QTypeTraits::compare_lt_result_container< QList, Uoperator< (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, Uoperator> (const QList &other) const noexcept(noexcept(other< std::declval< QList< U >>()))
 
QTypeTraits::compare_lt_result_container< QList, Uoperator<= (const QList &other) const noexcept(noexcept(other< std::declval< QList< U >>()))
 
QTypeTraits::compare_lt_result_container< QList, Uoperator>= (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)
 
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+ (QList< QPointF > &&l) const
 
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 Functions

(Note that these are not member functions.)

QDataStreamoperator<< (QDataStream &stream, const QPolygonF &polygon)
 
QDataStreamoperator>> (QDataStream &stream, QPolygonF &polygon)
 

Additional Inherited Members

- Public Types inherited from QList< QPointF >
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 Public Member Functions inherited from QList< QPointF >
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< QPointF >
 ~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:

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 127 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 > &  points)
inline

Constructs a polygon containing the specified points.

Definition at line 132 of file qpolygon.h.

◆ QPolygonF() [3/5]

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

Definition at line 133 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 520 of file qpolygon.cpp.

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

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

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

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

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

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 148 of file qpolygon.h.

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

◆ operator QVariant()

QPolygonF::operator QVariant ( ) const

Returns the polygon as a QVariant.

Definition at line 997 of file qpolygon.cpp.

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

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 136 of file qpolygon.h.

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

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

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 174 of file qpolygon.h.

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

◆ 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 177 of file qpolygon.h.

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

Here is the call graph for this function:

Friends And Related Function 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 729 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 750 of file qpolygon.cpp.


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