summaryrefslogtreecommitdiffstats
path: root/src/gui/math3d/qvector2d.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/math3d/qvector2d.cpp')
-rw-r--r--src/gui/math3d/qvector2d.cpp46
1 files changed, 42 insertions, 4 deletions
diff --git a/src/gui/math3d/qvector2d.cpp b/src/gui/math3d/qvector2d.cpp
index 9b5d123e6e..28f6b7ae22 100644
--- a/src/gui/math3d/qvector2d.cpp
+++ b/src/gui/math3d/qvector2d.cpp
@@ -57,9 +57,7 @@ QT_BEGIN_NAMESPACE
The QVector2D class can also be used to represent vertices in 2D space.
We therefore do not need to provide a separate vertex class.
- The coordinates are stored internally using the most efficient
- representation for the GL rendering engine, which will be either
- floating-point or fixed-point.
+ \sa QVector3D, QVector4D, QQuaternion
*/
/*!
@@ -412,6 +410,46 @@ QDebug operator<<(QDebug dbg, const QVector2D &vector)
#endif
-#endif
+#ifndef QT_NO_DATASTREAM
+
+/*!
+ \fn QDataStream &operator<<(QDataStream &stream, const QVector2D &vector)
+ \relates QVector2D
+
+ Writes the given \a vector to the given \a stream and returns a
+ reference to the stream.
+
+ \sa {Format of the QDataStream Operators}
+*/
+
+QDataStream &operator<<(QDataStream &stream, const QVector2D &vector)
+{
+ stream << double(vector.x()) << double(vector.y());
+ return stream;
+}
+
+/*!
+ \fn QDataStream &operator>>(QDataStream &stream, QVector2D &vector)
+ \relates QVector2D
+
+ Reads a 2D vector from the given \a stream into the given \a vector
+ and returns a reference to the stream.
+
+ \sa {Format of the QDataStream Operators}
+*/
+
+QDataStream &operator>>(QDataStream &stream, QVector2D &vector)
+{
+ double x, y;
+ stream >> x;
+ stream >> y;
+ vector.setX(qreal(x));
+ vector.setY(qreal(y));
+ return stream;
+}
+
+#endif // QT_NO_DATASTREAM
+
+#endif // QT_NO_VECTOR2D
QT_END_NAMESPACE