- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Friends

# QVector2D Class Reference

Search for all occurrences

## Detailed Description

Definition at line 60 of file qvector2d.h.

`#include <qvector2d.h>`

List of all members.

## Public Member Functions
| QVector2D ()
| QVector2D (qreal xpos, qreal ypos)
| QVector2D (const QPoint &point)
| QVector2D (const QPointF &point)
| QVector2D (const QVector3D &vector)
| QVector2D (const QVector4D &vector)
bool | isNull () const
qreal | x () const
qreal | y () const
void | setX (qreal x)
void | setY (qreal y)
qreal | length () const
qreal | lengthSquared () const
QVector2D | normalized () const
void | normalize ()
QVector2D & | operator+= (const QVector2D &vector)
QVector2D & | operator-= (const QVector2D &vector)
QVector2D & | operator*= (qreal factor)
QVector2D & | operator*= (const QVector2D &vector)
QVector2D & | operator/= (qreal divisor)
QVector3D | toVector3D () const
QVector4D | toVector4D () const
QPoint | toPoint () const
QPointF | toPointF () const
| operator QVariant () const
## Static Public Member Functions
static qreal | dotProduct (const QVector2D &v1, const QVector2D &v2)
## Friends
class | QVector3D
class | QVector4D
bool | operator== (const QVector2D &v1, const QVector2D &v2)
bool | operator!= (const QVector2D &v1, const QVector2D &v2)
const QVector2D | operator+ (const QVector2D &v1, const QVector2D &v2)
const QVector2D | operator- (const QVector2D &v1, const QVector2D &v2)
const QVector2D | operator* (qreal factor, const QVector2D &vector)
const QVector2D | operator* (const QVector2D &vector, qreal factor)
const QVector2D | operator* (const QVector2D &v1, const QVector2D &v2)
const QVector2D | operator- (const QVector2D &vector)
const QVector2D | operator/ (const QVector2D &vector, qreal divisor)
bool | qFuzzyCompare (const QVector2D &v1, const QVector2D &v2)

## Constructor & Destructor Documentation

QVector2D | ( |  | ) | `[inline]`

Definition at line 131 of file qvector2d.h.

    : xp(0.0f), yp(0.0f) {}

QVector2D | ( | qreal | xpos,
|  | qreal | ypos
| ) |  | `[inline]`

Definition at line 135 of file qvector2d.h.

    : xp(xpos), yp(ypos) {}

QVector2D | ( | const QPoint & | point | ) | `[inline, explicit]`

Definition at line 137 of file qvector2d.h.

    : xp(point.x()), yp(point.y()) {}

QVector2D | ( | const QPointF & | point | ) | `[inline, explicit]`

Definition at line 139 of file qvector2d.h.

    : xp(point.x()), yp(point.y()) {}

QVector2D | ( | const QVector3D & | vector | ) | `[explicit]`

QVector2D | ( | const QVector4D & | vector | ) | `[explicit]`

## Member Function Documentation

bool isNull | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 141 of file qvector2d.h.

    {
        return qIsNull(xp) && qIsNull(yp);
    }

qreal x | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 146 of file qvector2d.h.

    { return qreal(xp); }

qreal y | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 147 of file qvector2d.h.

    { return qreal(yp); }

void setX | ( | qreal | x | ) | `[inline]`

Search for all occurrences

Definition at line 149 of file qvector2d.h.

    { xp = aX; }

void setY | ( | qreal | y | ) | `[inline]`

Search for all occurrences

Definition at line 150 of file qvector2d.h.

    { yp = aY; }

qreal length | ( |  | ) | const

Search for all occurrences

qreal lengthSquared | ( |  | ) | const

Search for all occurrences

QVector2D normalized | ( |  | ) | const

Search for all occurrences

void normalize | ( |  | ) |

Search for all occurrences

QVector2D & operator+= | ( | const QVector2D & | vector | ) | `[inline]`

Definition at line 152 of file qvector2d.h.

    {
        xp += vector.xp;
        yp += vector.yp;
        return *this;
    }

QVector2D & operator-= | ( | const QVector2D & | vector | ) | `[inline]`

Definition at line 159 of file qvector2d.h.

    {
        xp -= vector.xp;
        yp -= vector.yp;
        return *this;
    }

QVector2D & operator*= | ( | qreal | factor | ) | `[inline]`

Definition at line 166 of file qvector2d.h.

    {
        xp *= factor;
        yp *= factor;
        return *this;
    }

QVector2D & operator*= | ( | const QVector2D & | vector | ) | `[inline]`

Definition at line 173 of file qvector2d.h.

    {
        xp *= vector.xp;
        yp *= vector.yp;
        return *this;
    }

QVector2D & operator/= | ( | qreal | divisor | ) | `[inline]`

Definition at line 180 of file qvector2d.h.

    {
        xp /= divisor;
        yp /= divisor;
        return *this;
    }

static qreal dotProduct | ( | const QVector2D & | v1,
|  | const QVector2D & | v2
| ) |  | `[static]`

Search for all occurrences

QVector3D toVector3D | ( |  | ) | const

Search for all occurrences

QVector4D toVector4D | ( |  | ) | const

Search for all occurrences

QPoint toPoint | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 237 of file qvector2d.h.

    {
        return QPoint(qRound(xp), qRound(yp));
    }

QPointF toPointF | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 242 of file qvector2d.h.

    {
        return QPointF(qreal(xp), qreal(yp));
    }

operator QVariant | ( |  | ) | const

## Friends And Related Function Documentation

friend class QVector3D `[friend]`

Search for all occurrences

Definition at line 125 of file qvector2d.h.

friend class QVector4D `[friend]`

Search for all occurrences

Definition at line 126 of file qvector2d.h.

bool operator== | ( | const QVector2D & | v1,
|  | const QVector2D & | v2
| ) |  | `[friend]`

Definition at line 187 of file qvector2d.h.

    {
        return v1.xp == v2.xp && v1.yp == v2.yp;
    }

bool operator!= | ( | const QVector2D & | v1,
|  | const QVector2D & | v2
| ) |  | `[friend]`

Definition at line 192 of file qvector2d.h.

    {
        return v1.xp != v2.xp || v1.yp != v2.yp;
    }

const QVector2D operator+ | ( | const QVector2D & | v1,
|  | const QVector2D & | v2
| ) |  | `[friend]`

Definition at line 197 of file qvector2d.h.

    {
        return QVector2D(v1.xp + v2.xp, v1.yp + v2.yp, 1);
    }

const QVector2D operator- | ( | const QVector2D & | v1,
|  | const QVector2D & | v2
| ) |  | `[friend]`

Definition at line 202 of file qvector2d.h.

    {
        return QVector2D(v1.xp - v2.xp, v1.yp - v2.yp, 1);
    }

const QVector2D operator* | ( | qreal | factor,
|  | const QVector2D & | vector
| ) |  | `[friend]`

Definition at line 207 of file qvector2d.h.

    {
        return QVector2D(vector.xp * factor, vector.yp * factor, 1);
    }

const QVector2D operator* | ( | const QVector2D & | vector,
|  | qreal | factor
| ) |  | `[friend]`

Definition at line 212 of file qvector2d.h.

    {
        return QVector2D(vector.xp * factor, vector.yp * factor, 1);
    }

const QVector2D operator* | ( | const QVector2D & | v1,
|  | const QVector2D & | v2
| ) |  | `[friend]`

Definition at line 217 of file qvector2d.h.

    {
        return QVector2D(v1.xp * v2.xp, v1.yp * v2.yp, 1);
    }

const QVector2D operator- | ( | const QVector2D & | vector | ) | `[friend]`

Definition at line 222 of file qvector2d.h.

    {
        return QVector2D(-vector.xp, -vector.yp, 1);
    }

const QVector2D operator/ | ( | const QVector2D & | vector,
|  | qreal | divisor
| ) |  | `[friend]`

Definition at line 227 of file qvector2d.h.

    {
        return QVector2D(vector.xp / divisor, vector.yp / divisor, 1);
    }

bool qFuzzyCompare | ( | const QVector2D & | v1,
|  | const QVector2D & | v2
| ) |  | `[friend]`

Search for all occurrences

Definition at line 232 of file qvector2d.h.

    {
        return qFuzzyCompare(v1.xp, v2.xp) && qFuzzyCompare(v1.yp, v2.yp);
    }

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

- QtGui/qvector2d.h

QVector2D QVector2D QVector2D QVector2D QVector2D QVector2D QVector2D QVector2D QVector2D QVector2D
QVector2D QVector2D QVector2D QVector2D QVector2D QVector2D QVector2D QVector2D QVector2D QVector2D