Qt 6.x
The Qt SDK
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
qpoint.cpp
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qpoint.h"
5#include "qdatastream.h"
6
7#include <private/qdebug_p.h>
8#include <QtCore/qhashfunctions.h>
9
11
47/*****************************************************************************
48 QPoint member functions
49 *****************************************************************************/
50
357/*****************************************************************************
358 QPoint stream functions
359 *****************************************************************************/
360#ifndef QT_NO_DATASTREAM
372{
373 if (s.version() == 1)
374 s << (qint16)p.x() << (qint16)p.y();
375 else
376 s << (qint32)p.x() << (qint32)p.y();
377 return s;
378}
379
391{
392 if (s.version() == 1) {
393 qint16 x, y;
394 s >> x; p.rx() = x;
395 s >> y; p.ry() = y;
396 }
397 else {
398 qint32 x, y;
399 s >> x; p.rx() = x;
400 s >> y; p.ry() = y;
401 }
402 return s;
403}
404
405#endif // QT_NO_DATASTREAM
425#ifndef QT_NO_DEBUG_STREAM
427{
428 QDebugStateSaver saver(dbg);
429 dbg.nospace();
430 dbg << "QPoint" << '(';
432 dbg << ')';
433 return dbg;
434}
435
437{
438 QDebugStateSaver saver(dbg);
439 dbg.nospace();
440 dbg << "QPointF" << '(';
442 dbg << ')';
443 return dbg;
444}
445#endif
446
455size_t qHash(QPoint key, size_t seed) noexcept
456{
457 return qHashMulti(seed, key.x(), key.y());
458}
459
756#ifndef QT_NO_DATASTREAM
768{
769 s << double(p.x()) << double(p.y());
770 return s;
771}
772
784{
785 double x, y;
786 s >> x;
787 s >> y;
788 p.setX(qreal(x));
789 p.setY(qreal(y));
790 return s;
791}
792#endif // QT_NO_DATASTREAM
793
\inmodule QtCore\reentrant
Definition qdatastream.h:30
\inmodule QtCore
\inmodule QtCore
\inmodule QtCore\reentrant
Definition qpoint.h:214
\inmodule QtCore\reentrant
Definition qpoint.h:23
Combined button and popup list for selecting options.
static void formatQPoint(QDebug &debug, const Point &point)
Definition qdebug_p.h:33
constexpr QtPrivate::QHashMultiReturnType< T... > qHashMulti(size_t seed, const T &... args) noexcept(std::conjunction_v< QtPrivate::QNothrowHashable< T >... >)
GLint GLint GLint GLint GLint x
[0]
GLuint64 key
GLint y
GLdouble s
[6]
Definition qopenglext.h:235
GLfloat GLfloat p
[1]
QDataStream & operator>>(QDataStream &s, QPoint &p)
Definition qpoint.cpp:390
QDataStream & operator<<(QDataStream &s, const QPoint &p)
Definition qpoint.cpp:371
size_t qHash(QPoint key, size_t seed) noexcept
Definition qpoint.cpp:455
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
Definition qrandom.cpp:196
short qint16
Definition qtypes.h:42
int qint32
Definition qtypes.h:44
double qreal
Definition qtypes.h:92