Qt 4.8
Public Functions | Related Functions | List of all members
QPolygonF Class Reference

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

#include <qpolygon.h>

Inheritance diagram for QPolygonF:
QVector< QPointF >

Public Functions

QRectF boundingRect () const
 Returns the bounding rectangle of the polygon, or QRectF(0,0,0,0) if the polygon is empty. More...
 
bool containsPoint (const QPointF &pt, Qt::FillRule fillRule) const
 Returns true if the given point is inside the polygon according to the specified fillRule; otherwise returns false. More...
 
QPolygonF intersected (const QPolygonF &r) const
 Returns a polygon which is the intersection of this polygon and r. More...
 
bool isClosed () const
 Returns true if the polygon is closed; otherwise returns false. More...
 
 QPolygonF ()
 Constructs a polygon with no points. More...
 
 QPolygonF (int size)
 Constructs a polygon of the given size. More...
 
 QPolygonF (const QPolygonF &a)
 Constructs a copy of the given polygon. More...
 
 QPolygonF (const QVector< QPointF > &v)
 Constructs a polygon containing the specified points. More...
 
 QPolygonF (const QRectF &r)
 Constructs a closed polygon from the specified rectangle. More...
 
 QPolygonF (const QPolygon &a)
 Constructs a float based polygon from the specified integer based polygon. More...
 
QPolygonF subtracted (const QPolygonF &r) const
 Returns a polygon which is r subtracted from this polygon. More...
 
void swap (QPolygonF &other)
 Swaps polygon other with this polygon. More...
 
QPolygon toPolygon () const
 Creates and returns a QPolygon by converting each QPointF to a QPoint. More...
 
void translate (qreal dx, qreal dy)
 Translates all points in the polygon by ({dx}, {dy}). More...
 
void translate (const QPointF &offset)
 Translate all points in the polygon by the given offset. More...
 
QPolygonF translated (qreal dx, qreal dy) const
 Returns a copy of the polygon that is translated by ({dx}, {dy}). More...
 
QPolygonF translated (const QPointF &offset) const
 Returns a copy of the polygon that is translated by the given offset. More...
 
QPolygonF united (const QPolygonF &r) const
 Returns a polygon which is the union of this polygon and r. More...
 
 ~QPolygonF ()
 Destroys the polygon. More...
 
- Public Functions inherited from QVector< QPointF >
void append (const QPointF &t)
 Inserts value at the end of the vector. More...
 
const QPointFat (int i) const
 Returns the item at index position i in the vector. More...
 
reference back ()
 This function is provided for STL compatibility. More...
 
const_reference back () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
iterator begin ()
 Returns an STL-style iterator pointing to the first item in the vector. More...
 
const_iterator begin () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
int capacity () const
 Returns the maximum number of items that can be stored in the vector without forcing a reallocation. More...
 
void clear ()
 Removes all the elements from the vector and releases the memory used by the vector. More...
 
const_iterator constBegin () const
 Returns a const STL-style iterator pointing to the first item in the vector. More...
 
const QPointFconstData () const
 Returns a const pointer to the data stored in the vector. More...
 
const_iterator constEnd () const
 Returns a const STL-style iterator pointing to the imaginary item after the last item in the vector. More...
 
bool contains (const QPointF &t) const
 Returns true if the vector contains an occurrence of value; otherwise returns false. More...
 
int count (const QPointF &t) const
 Returns the number of occurrences of value in the vector. More...
 
int count () const
 Same as size(). More...
 
QPointFdata ()
 Returns a pointer to the data stored in the vector. More...
 
const QPointFdata () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
void detach ()
 
bool empty () const
 This function is provided for STL compatibility. More...
 
iterator end ()
 Returns an STL-style iterator pointing to the imaginary item after the last item in the vector. More...
 
const_iterator end () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
bool endsWith (const QPointF &t) const
 Returns true if this vector is not empty and its last item is equal to value; otherwise returns false. More...
 
iterator erase (iterator begin, iterator end)
 Removes all the items from begin up to (but not including) end. More...
 
iterator erase (iterator pos)
 Removes the item pointed to by the iterator pos from the vector, and returns an iterator to the next item in the vector (which may be end()). More...
 
QVector< QPointF > & fill (const QPointF &t, int size=-1)
 Assigns value to all items in the vector. More...
 
QPointFfirst ()
 Returns a reference to the first item in the vector. More...
 
const QPointFfirst () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
QPointFfront ()
 This function is provided for STL compatibility. More...
 
const_reference front () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
int indexOf (const QPointF &t, int from=0) const
 Returns the index position of the first occurrence of value in the vector, searching forward from index position from. More...
 
void insert (int i, const QPointF &t)
 Inserts value at index position i in the vector. More...
 
void insert (int i, int n, const QPointF &t)
 Inserts count copies of value at index position i in the vector. More...
 
iterator insert (iterator before, int n, const QPointF &x)
 Inserts count copies of value in front of the item pointed to by the iterator before. More...
 
iterator insert (iterator before, const QPointF &x)
 Inserts value in front of the item pointed to by the iterator before. More...
 
bool isDetached () const
 
bool isEmpty () const
 Returns true if the vector has size 0; otherwise returns false. More...
 
bool isSharedWith (const QVector< QPointF > &other) const
 
QPointFlast ()
 Returns a reference to the last item in the vector. More...
 
const QPointFlast () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
int lastIndexOf (const QPointF &t, int from=-1) const
 Returns the index position of the last occurrence of the value value in the vector, searching backward from index position from. More...
 
QVector< QPointFmid (int pos, int length=-1) const
 Returns a vector whose elements are copied from this vector, starting at position pos. More...
 
bool operator!= (const QVector< QPointF > &v) const
 Returns true if other is not equal to this vector; otherwise returns false. More...
 
QVector< QPointFoperator+ (const QVector< QPointF > &l) const
 Returns a vector that contains all the items in this vector followed by all the items in the other vector. More...
 
QVector< QPointF > & operator+= (const QVector< QPointF > &l)
 Appends the items of the other vector to this vector and returns a reference to this vector. More...
 
QVector< QPointF > & operator+= (const QPointF &t)
 Appends value to the vector. More...
 
QVector< QPointF > & operator<< (const QVector< QPointF > &l)
 Appends other to the vector and returns a reference to the vector. More...
 
QVector< QPointF > & operator<< (const QPointF &t)
 Appends value to the vector and returns a reference to this vector. More...
 
QVector< QPointF > & operator= (const QVector< QPointF > &v)
 Assigns other to this vector and returns a reference to this vector. More...
 
bool operator== (const QVector< QPointF > &v) const
 Returns true if other is equal to this vector; otherwise returns false. More...
 
QPointFoperator[] (int i)
 Returns the item at index position i as a modifiable reference. More...
 
const QPointFoperator[] (int i) const
 Same as at(i). More...
 
void pop_back ()
 This function is provided for STL compatibility. More...
 
void pop_front ()
 This function is provided for STL compatibility. More...
 
void prepend (const QPointF &t)
 Inserts value at the beginning of the vector. More...
 
void push_back (const QPointF &t)
 This function is provided for STL compatibility. More...
 
void push_front (const QPointF &t)
 This function is provided for STL compatibility. More...
 
 QVector ()
 Constructs an empty vector. More...
 
 QVector (int size)
 Constructs a vector with an initial size of size elements. More...
 
 QVector (int size, const QPointF &t)
 Constructs a vector with an initial size of size elements. More...
 
 QVector (const QVector< QPointF > &v)
 Constructs a copy of other. More...
 
void remove (int i)
 Removes the element at index position i. More...
 
void remove (int i, int n)
 Removes count elements from the middle of the vector, starting at index position i. More...
 
void replace (int i, const QPointF &t)
 Replaces the item at index position i with value. More...
 
void reserve (int size)
 Attempts to allocate memory for at least size elements. More...
 
void resize (int size)
 Sets the size of the vector to size. More...
 
void setSharable (bool sharable)
 
int size () const
 Returns the number of items in the vector. More...
 
void squeeze ()
 Releases any memory not required to store the items. More...
 
bool startsWith (const QPointF &t) const
 Returns true if this vector is not empty and its first item is equal to value; otherwise returns false. More...
 
void swap (QVector< QPointF > &other)
 Swaps vector other with this vector. More...
 
QList< QPointFtoList () const
 Returns a QList object with the data contained in this QVector. More...
 
std::vector< QPointFtoStdVector () const
 Returns a std::vector object with the data contained in this QVector. More...
 
QPointF value (int i) const
 Returns the value at index position i in the vector. More...
 
QPointF value (int i, const QPointF &defaultValue) const
 If the index i is out of bounds, the function returns defaultValue. More...
 
 ~QVector ()
 Destroys the vector. More...
 

Related Functions

(Note that these are not member functions.)

QDataStreamoperator<< (QDataStream &stream, const QPolygonF &polygon)
 Writes the given polygon to the given stream, and returns a reference to the stream. More...
 
QDataStreamoperator>> (QDataStream &stream, QPolygonF &polygon)
 Reads a polygon from the given stream into the given polygon, and returns a reference to the stream. More...
 

Additional Inherited Members

- Public Types inherited from QVector< QPointF >
typedef const QPointFconst_iterator
 The QVector::const_iterator typedef provides an STL-style const iterator for QVector and QStack. More...
 
typedef const value_typeconst_pointer
 Typedef for const T *. More...
 
typedef const value_typeconst_reference
 Typedef for T &. More...
 
typedef const_iterator ConstIterator
 Qt-style synonym for QVector::const_iterator. More...
 
typedef qptrdiff difference_type
 Typedef for ptrdiff_t. More...
 
typedef QPointFiterator
 The QVector::iterator typedef provides an STL-style non-const iterator for QVector and QStack. More...
 
typedef iterator Iterator
 Qt-style synonym for QVector::iterator. More...
 
typedef value_typepointer
 Typedef for T *. More...
 
typedef value_typereference
 Typedef for T &. More...
 
typedef int size_type
 Typedef for int. More...
 
typedef QPointF value_type
 Typedef for T. More...
 
- Static Public Functions inherited from QVector< QPointF >
static QVector< QPointFfromList (const QList< QPointF > &list)
 Returns a QVector object with the data contained in list. More...
 
static QVector< QPointFfromStdVector (const std::vector< QPointF > &vector)
 Returns a QVector object with the data contained in vector. More...
 
- Public Variables inherited from QVector< QPointF >
QVectorDatad
 
Datap
 

Detailed Description

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

Note
This class or function is reentrant.

A QPolygonF is a QVector<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 QVector, QPolygonF provides the boundingRect() and translate() functions for geometry operations. Use the QMatrix::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 Implicit Data Sharing.

See also
QVector, QPolygon, QLineF

Definition at line 134 of file qpolygon.h.

Constructors and Destructors

◆ QPolygonF() [1/6]

QPolygonF::QPolygonF ( )
inline

Constructs a polygon with no points.

See also
QVector::isEmpty()

Definition at line 137 of file qpolygon.h.

137 {}

◆ ~QPolygonF()

QPolygonF::~QPolygonF ( )
inline

Destroys the polygon.

Definition at line 138 of file qpolygon.h.

138 {}

◆ QPolygonF() [2/6]

QPolygonF::QPolygonF ( int  size)
inline

Constructs a polygon of the given size.

Creates an empty polygon if size == 0.

See also
QVector::isEmpty()

Definition at line 165 of file qpolygon.h.

◆ QPolygonF() [3/6]

QPolygonF::QPolygonF ( const QPolygonF a)
inline

Constructs a copy of the given polygon.

Definition at line 140 of file qpolygon.h.

140 : QVector<QPointF>(a) {}
long ASN1_INTEGER_get ASN1_INTEGER * a

◆ QPolygonF() [4/6]

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

Constructs a polygon containing the specified points.

Definition at line 141 of file qpolygon.h.

◆ QPolygonF() [5/6]

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

627 {
628  reserve(5);
629  append(QPointF(r.x(), r.y()));
630  append(QPointF(r.x() + r.width(), r.y()));
631  append(QPointF(r.x() + r.width(), r.y() + r.height()));
632  append(QPointF(r.x(), r.y() + r.height()));
633  append(QPointF(r.x(), r.y()));
634 }
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
void append(const QPointF &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
void reserve(int size)
Attempts to allocate memory for at least size elements.
Definition: qvector.h:339

◆ QPolygonF() [6/6]

QPolygonF::QPolygonF ( const QPolygon polygon)

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

See also
toPolygon()

Definition at line 648 of file qpolygon.cpp.

649 {
650  reserve(a.size());
651  for (int i=0; i<a.size(); ++i)
652  append(a.at(i));
653 }
long ASN1_INTEGER_get ASN1_INTEGER * a
void append(const QPointF &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
void reserve(int size)
Attempts to allocate memory for at least size elements.
Definition: qvector.h:339

Functions

◆ 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
QVector::isEmpty()

Definition at line 742 of file qpolygon.cpp.

Referenced by QGLPathMaskGenerator::computeScreenRect(), QPicturePaintEngine::drawPolygon(), QGraphicsSceneIndex::items(), QMacPixmapData::macCreatePixels(), QGraphicsViewPrivate::mapToScene(), QAccessibleDial::rect(), QGraphicsView::render(), QPainterPath::toFillPolygons(), QX11PixmapData::transformed(), and QImage::transformed().

743 {
744  if (isEmpty())
745  return QRectF(0, 0, 0, 0);
746  register const QPointF *pd = constData();
747  qreal minx, maxx, miny, maxy;
748  minx = maxx = pd->x();
749  miny = maxy = pd->y();
750  ++pd;
751  for (int i = 1; i < size(); ++i) {
752  if (pd->x() < minx)
753  minx = pd->x();
754  else if (pd->x() > maxx)
755  maxx = pd->x();
756  if (pd->y() < miny)
757  miny = pd->y();
758  else if (pd->y() > maxy)
759  maxy = pd->y();
760  ++pd;
761  }
762  return QRectF(minx,miny, maxx - minx, maxy - miny);
763 }
double qreal
Definition: qglobal.h:1193
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
Definition: qvector.h:139
const QPointF * constData() const
Returns a const pointer to the data stored in the vector.
Definition: qvector.h:154
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ containsPoint()

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.

Since
4.3

Definition at line 940 of file qpolygon.cpp.

941 {
942  if (isEmpty())
943  return false;
944 
945  int winding_number = 0;
946 
947  QPointF last_pt = at(0);
948  QPointF last_start = at(0);
949  for (int i = 1; i < size(); ++i) {
950  const QPointF &e = at(i);
951  qt_polygon_isect_line(last_pt, e, pt, &winding_number);
952  last_pt = e;
953  }
954 
955  // implicitly close last subpath
956  if (last_pt != last_start)
957  qt_polygon_isect_line(last_pt, last_start, pt, &winding_number);
958 
959  return (fillRule == Qt::WindingFill
960  ? (winding_number != 0)
961  : ((winding_number % 2) != 0));
962 }
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
static void qt_polygon_isect_line(const QPointF &p1, const QPointF &p2, const QPointF &pos, int *winding)
Definition: qpolygon.cpp:57
const QPointF & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
Definition: qvector.h:139
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ intersected()

QPolygonF QPolygonF::intersected ( const QPolygonF r) const

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

Since
4.3

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

Definition at line 1096 of file qpolygon.cpp.

1097 {
1098  QPainterPath subject; subject.addPolygon(*this);
1099  QPainterPath clip; clip.addPolygon(r);
1100 
1101  return subject.intersected(clip).toFillPolygon();
1102 }
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
QPainterPath intersected(const QPainterPath &r) const
Returns a path which is the intersection of this path&#39;s fill area and p&#39;s fill area.
void addPolygon(const QPolygonF &polygon)
Adds the given polygon to the path as an (unclosed) subpath.
QPolygonF toFillPolygon(const QMatrix &matrix=QMatrix()) const
This is an overloaded member function, provided for convenience. It differs from the above function o...

◆ 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
QVector::first(), QVector::last()

Definition at line 154 of file qpolygon.h.

Referenced by QPainterPath::toFillPolygon(), and QPainterPath::toFillPolygons().

154 { return !isEmpty() && first() == last(); }
QPointF & first()
Returns a reference to the first item in the vector.
Definition: qvector.h:260
QPointF & last()
Returns a reference to the last item in the vector.
Definition: qvector.h:262
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
Definition: qvector.h:139

◆ subtracted()

QPolygonF QPolygonF::subtracted ( const QPolygonF r) const

Returns a polygon which is r subtracted from this polygon.

Since
4.3

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

Definition at line 1117 of file qpolygon.cpp.

1118 {
1119  QPainterPath subject; subject.addPolygon(*this);
1120  QPainterPath clip; clip.addPolygon(r);
1121  return subject.subtracted(clip).toFillPolygon();
1122 }
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
QPainterPath subtracted(const QPainterPath &r) const
Returns a path which is p&#39;s fill area subtracted from this path&#39;s fill area.
void addPolygon(const QPolygonF &polygon)
Adds the given polygon to the path as an (unclosed) subpath.
QPolygonF toFillPolygon(const QMatrix &matrix=QMatrix()) const
This is an overloaded member function, provided for convenience. It differs from the above function o...

◆ swap()

void QPolygonF::swap ( QPolygonF other)
inline

Swaps polygon other with this polygon.

Since
4.8

This operation is very fast and never fails.

Definition at line 144 of file qpolygon.h.

144 { QVector<QPointF>::swap(other); } // prevent QVector<QPointF><->QPolygonF swaps
void swap(QVector< T > &other)
Swaps vector other with this vector.
Definition: qvector.h:130

◆ toPolygon()

QPolygon QPolygonF::toPolygon ( ) const

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

See also
QPointF::toPoint()

Definition at line 772 of file qpolygon.cpp.

Referenced by QOpenGLPaintEngine::clip(), clipTransformIsSimple(), QPolygon::intersected(), QMatrix::map(), QTransform::map(), QPolygon::subtracted(), QX11PaintEnginePrivate::systemStateChanged(), QPolygon::united(), QCoreGraphicsPaintEngine::updateClipPath(), QX11PaintEngine::updateState(), and QOpenGLPaintEngine::updateState().

773 {
774  QPolygon a;
775  a.reserve(size());
776  for (int i=0; i<size(); ++i)
777  a.append(at(i).toPoint());
778  return a;
779 }
long ASN1_INTEGER_get ASN1_INTEGER * a
The QPolygon class provides a vector of points using integer precision.
Definition: qpolygon.h:60
void append(const T &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
const QPointF & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
void reserve(int size)
Attempts to allocate memory for at least size elements.
Definition: qvector.h:339
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ translate() [1/2]

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

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

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

See also
translated()

Definition at line 179 of file qpolygon.h.

Referenced by translated().

180 { translate(QPointF(dx, dy)); }
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
void translate(qreal dx, qreal dy)
Translates all points in the polygon by ({dx}, {dy}).
Definition: qpolygon.h:179

◆ translate() [2/2]

void QPolygonF::translate ( const QPointF offset)

Translate all points in the polygon by the given offset.

See also
translated()

Definition at line 671 of file qpolygon.cpp.

672 {
673  if (offset.isNull())
674  return;
675 
676  register QPointF *p = data();
677  register int i = size();
678  while (i--) {
679  *p += offset;
680  ++p;
681  }
682 }
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
bool isNull() const
Returns true if both the x and y coordinates are set to +0.
Definition: qpoint.h:277
QPointF * data()
Returns a pointer to the data stored in the vector.
Definition: qvector.h:152
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ translated() [1/2]

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

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

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
See also
translate()

Definition at line 182 of file qpolygon.h.

Referenced by QTransform::map(), QGraphicsItem::mapFromParent(), QGraphicsItem::mapFromScene(), QGraphicsItem::mapToParent(), and QGraphicsItem::mapToScene().

183 { return translated(QPointF(dx, dy)); }
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
QPolygonF translated(qreal dx, qreal dy) const
Returns a copy of the polygon that is translated by ({dx}, {dy}).
Definition: qpolygon.h:182

◆ translated() [2/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 702 of file qpolygon.cpp.

703 {
704  QPolygonF copy(*this);
705  copy.translate(offset);
706  return copy;
707 }
The QPolygonF class provides a vector of points using floating point precision.
Definition: qpolygon.h:134

◆ united()

QPolygonF QPolygonF::united ( const QPolygonF r) const

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

Since
4.3

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

1076 {
1077  QPainterPath subject; subject.addPolygon(*this);
1078  QPainterPath clip; clip.addPolygon(r);
1079 
1080  return subject.united(clip).toFillPolygon();
1081 }
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
void addPolygon(const QPolygonF &polygon)
Adds the given polygon to the path as an (unclosed) subpath.
QPolygonF toFillPolygon(const QMatrix &matrix=QMatrix()) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
QPainterPath united(const QPainterPath &r) const
Returns a path which is the union of this path&#39;s fill area and p&#39;s fill area.

Friends and Related Functions

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

Referenced by QPolygonF().

872 {
873  quint32 len = a.size();
874  uint i;
875 
876  s << len;
877  for (i = 0; i < len; ++i)
878  s << a.at(i);
879  return s;
880 }
long ASN1_INTEGER_get ASN1_INTEGER * a
unsigned int uint
Definition: qglobal.h:996
unsigned int quint32
Definition: qglobal.h:938

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

Referenced by QPolygonF().

896 {
897  quint32 len;
898  uint i;
899 
900  s >> len;
901  a.reserve(a.size() + (int)len);
902  QPointF p;
903  for (i = 0; i < len; ++i) {
904  s >> p;
905  a.insert(i, p);
906  }
907  return s;
908 }
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
long ASN1_INTEGER_get ASN1_INTEGER * a
unsigned int uint
Definition: qglobal.h:996
unsigned int quint32
Definition: qglobal.h:938

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