Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
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
51/*****************************************************************************
52 QPoint member functions
53 *****************************************************************************/
54
362/*****************************************************************************
363 QPoint stream functions
364 *****************************************************************************/
365#ifndef QT_NO_DATASTREAM
377{
378 if (s.version() == 1)
379 s << (qint16)p.x() << (qint16)p.y();
380 else
381 s << (qint32)p.x() << (qint32)p.y();
382 return s;
383}
384
396{
397 if (s.version() == 1) {
398 qint16 x, y;
399 s >> x; p.rx() = x;
400 s >> y; p.ry() = y;
401 }
402 else {
403 qint32 x, y;
404 s >> x; p.rx() = x;
405 s >> y; p.ry() = y;
406 }
407 return s;
408}
409
410#endif // QT_NO_DATASTREAM
430#ifndef QT_NO_DEBUG_STREAM
432{
433 QDebugStateSaver saver(dbg);
434 dbg.nospace();
435 dbg << "QPoint" << '(';
437 dbg << ')';
438 return dbg;
439}
440
442{
443 QDebugStateSaver saver(dbg);
444 dbg.nospace();
445 dbg << "QPointF" << '(';
447 dbg << ')';
448 return dbg;
449}
450#endif
451
460size_t qHash(QPoint key, size_t seed) noexcept
461{
462 return qHashMulti(seed, key.x(), key.y());
463}
464
785#ifndef QT_NO_DATASTREAM
797{
798 s << double(p.x()) << double(p.y());
799 return s;
800}
801
813{
814 double x, y;
815 s >> x;
816 s >> y;
817 p.setX(qreal(x));
818 p.setY(qreal(y));
819 return s;
820}
821#endif // QT_NO_DATASTREAM
822
\inmodule QtCore\reentrant
Definition qdatastream.h:46
\inmodule QtCore
\inmodule QtCore
\inmodule QtCore\reentrant
Definition qpoint.h:217
\inmodule QtCore\reentrant
Definition qpoint.h:25
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:395
QDataStream & operator<<(QDataStream &s, const QPoint &p)
Definition qpoint.cpp:376
size_t qHash(QPoint key, size_t seed) noexcept
Definition qpoint.cpp:460
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
Definition qrandom.cpp:196
short qint16
Definition qtypes.h:47
int qint32
Definition qtypes.h:49
double qreal
Definition qtypes.h:187