| |||
| Classes - Annotated - Tree - Functions - Home - Structure | |||
The QPointArray class provides an array of points. More...
#include <qpointarray.h>
Inherits QMemArray<QPoint>.
The QPointArray is an array of QPoint objects. In addition to the functions provided by QMemArray, QPointArray provides some point-specific functions.
For convenient reading and writing of the point data: setPoints(), putPoints(), point(), and setPoint().
For geometry operations: boundingRect() and translate(). There is also a QWMatrix::map() function for more general transformation of QPointArrays.
Among others, QPointArray is used by QPainter::drawLineSegments(), QPainter::drawPolyline(), QPainter::drawPolygon() and QPainter::drawCubicBezier().
Note that because this class is a QMemArray, copying an array and modifying the copy modifies the original as well - the copy is shallow, not deep. You must detach() the array in code like this:
void drawGiraffe( const QPointArray & r, QPainter * p )
{
QPointArray tmp = r;
tmp.detach();
// some code that modifies tmp
p->drawPoints( tmp );
}
If you forget the tmp.detach(), the const array will be modified.
See also QPainter, QWMatrix and QMemArray.
See also isNull().
Constructs a point array with room for size points. Makes a null array if size == 0.
See also resize() and isNull().
Constructs a shallow copy of the point array a.
See also copy().
If closed is FALSE, then the point array just contains the following four points in the listed order: r.topLeft(), r.topRight(), r.bottomRight() and r.bottomLeft().
If closed is TRUE, then a fifth point is set to r.topLeft().
Equivalent to setPoints(nPoints,points).
Destroys the point array.
Creates a deep copy of the array.
Angles are specified in 16ths of a degree, i.e., a full circle equals 5760 (16*360). Positive values mean counter-clockwise, whereas negative values mean a clockwise direction. Zero degrees is at the 3 o'clock position.
Angles are specified in 16ths of a degree, i.e., a full circle equals 5760 (16*360). Positive values mean counter-clockwise, whereas negative values mean a clockwise direction. Zero degrees is at the 3 o'clock position.
The returned array has sufficient resolution for use as pixels.
Assigns a shallow copy of a to this point array and returns a reference to this point array.
Equivalent to assign(a).
See also copy().
index+nPoints exceeds the size of the array.
Returns TRUE if successful, or FALSE if the array could not be resized (typically due to lack of memory).
The example code creates an array with three points (1,2), (3,4) and (5,6), by expanding the array from 1 to 3 points:
QPointArray a( 1 );
a[0] = QPoint( 1, 2 );
a.putPoints( 1, 2, 3,4, 5,6 );
This has the same result, but here putPoints overwrites rather than extends:
QPointArray a( 3 );
a.putPoints( 0, 3, 1,2, 0,0, 5,6 );
a.putPoints( 1, 1, 3,4 );
See also resize() and setPoints().
This version of the function copies nPoints from from into this array, starting at index in this array and fromIndex in from. fromIndex is 0 by default.
QPointArray a;
a.putPoints( 0, 3, 1,2, 0,0, 5,6 );
// a is now the three-point array ( 1,2, 0,0, 5,6 );
QPointArray b;
b.putPoints( 0, 3, 4,4, 5,5, 6,6 );
// b is now ( 4,4, 5,5, 6,6 );
a.putPoints( 2, 3, b );
// a is now ( 1,2, 0,0, 4,4, 5,5, 6,6 );
Example: themes/wood.cpp.
Returns TRUE if successful, or FALSE if the array could not be resized (normally due to lack of memory).
The example code creates an array with two points (1,2) and (3,4):
static QCOORD points[] = { 1,2, 3,4 };
QPointArray a;
a.setPoints( 2, points );
See also resize() and putPoints().
Examples: aclock/aclock.cpp, picture/picture.cpp, themes/metal.cpp and themes/wood.cpp.
Returns TRUE if successful, or FALSE if the array could not be resized (typically due to lack of memory).
The example code creates an array with two points (1,2) and (3,4):
QPointArray a;
a.setPoints( 2, 1,2, 3,4 );
See also resize() and putPoints().
See also Format of the QDataStream operators.
See also Format of the QDataStream operators.
Search the documentation, FAQ, qt-interest archive and more (uses
www.trolltech.com):
This file is part of the Qt toolkit, copyright © 1995-2000 Trolltech, all rights reserved.
| Copyright © 2000 Trolltech | Trademarks | Qt version main-beta1
|