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
src_corelib_tools_qpoint.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
6
7p.setX(p.x() + 1);
8p += QPoint(1, 0);
9p.rx()++;
11
12
14QPoint p(1, 2);
15p.rx()--; // p becomes (0, 2)
17
18
20QPoint p(1, 2);
21p.ry()++; // p becomes (1, 3)
23
24
26QPoint p( 3, 7);
27QPoint q(-1, 4);
28p += q; // p becomes (2, 11)
30
31
33QPoint p( 3, 7);
34QPoint q(-1, 4);
35p -= q; // p becomes (4, 3)
37
38
40QPoint p(-1, 4);
41p *= 2.5; // p becomes (-3, 10)
43
44
46QPoint p( 3, 7);
47QPoint q(-1, 4);
48int dotProduct = QPoint::dotProduct(p, q); // dotProduct becomes 25
50
51
53QPoint p(-3, 10);
54p /= 2.5; // p becomes (-1, 4)
56
57
60
62{
63 QPoint point = event->pos() - oldPosition;
64 if (point.manhattanLength() > 3)
65 // the mouse has moved more than 3 pixels since the oldPosition
66}
68
69
71double trueLength = std::sqrt(std::pow(x(), 2) + std::pow(y(), 2));
73
74
77
78p.setX(p.x() + 1.0);
79p += QPointF(1.0, 0.0);
80p.rx()++;
82
83
85 QPointF p(1.1, 2.5);
86 p.rx()--; // p becomes (0.1, 2.5)
88
89
91QPointF p(1.1, 2.5);
92p.ry()++; // p becomes (1.1, 3.5)
94
95
97QPointF p( 3.1, 7.1);
98QPointF q(-1.0, 4.1);
99p += q; // p becomes (2.1, 11.2)
101
102
104QPointF p( 3.1, 7.1);
105QPointF q(-1.0, 4.1);
106p -= q; // p becomes (4.1, 3.0)
108
109
111QPointF p(-1.1, 4.1);
112p *= 2.5; // p becomes (-2.75, 10.25)
114
115
117QPointF p(-2.75, 10.25);
118p /= 2.5; // p becomes (-1.1, 4.1)
120
121
123QPointF p( 3.1, 7.1);
124QPointF q(-1.0, 4.1);
125qreal dotProduct = QPointF::dotProduct(p, q); // dotProduct becomes 26.01
\inmodule QtGui
Definition qevent.h:196
\inmodule QtCore\reentrant
Definition qpoint.h:217
static constexpr qreal dotProduct(const QPointF &p1, const QPointF &p2)
Definition qpoint.h:242
\inmodule QtCore\reentrant
Definition qpoint.h:25
static constexpr int dotProduct(const QPoint &p1, const QPoint &p2)
Definition qpoint.h:53
constexpr int manhattanLength() const
Returns the sum of the absolute values of x() and y(), traditionally known as the "Manhattan length" ...
Definition qpoint.h:150
constexpr void setX(int x) noexcept
Sets the x coordinate of this point to the given x coordinate.
Definition qpoint.h:140
virtual void mouseMoveEvent(QMouseEvent *event)
This event handler, for event event, can be reimplemented in a subclass to receive mouse move events ...
Definition qwidget.cpp:9461
GLint GLint GLint GLint GLint x
[0]
GLint y
struct _cl_event * event
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLfloat GLfloat p
[1]
double qreal
Definition qtypes.h:187
QPoint q(-1, 4)
QPoint oldPosition
[6]
QPoint p
[0]
double trueLength
[7]