summaryrefslogtreecommitdiffstats
path: root/examples/widgets/widgets
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-06-04 18:07:06 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2020-06-08 19:11:51 +0200
commita061a646429c6e9d695458fc0ecb0021a30e12ee (patch)
tree7ba6fce7ee7c8975b0c50e31195bd02c5419fc15 /examples/widgets/widgets
parent24e52c10deedbaef833c0e2c3ee7bee03eacc4f5 (diff)
Replace calls to deprecated QEvent accessor functions
Many of these were generated by clazy using the new qevent-accessors check. Change-Id: Ie17af17f50fdc9f47d7859d267c14568cc350fd0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'examples/widgets/widgets')
-rw-r--r--examples/widgets/widgets/charactermap/characterwidget.cpp6
-rw-r--r--examples/widgets/widgets/scribble/scribblearea.cpp6
-rw-r--r--examples/widgets/widgets/shapedclock/shapedclock.cpp4
-rw-r--r--examples/widgets/widgets/tablet/tabletcanvas.cpp16
-rw-r--r--examples/widgets/widgets/tooltips/sortingbox.cpp8
5 files changed, 20 insertions, 20 deletions
diff --git a/examples/widgets/widgets/charactermap/characterwidget.cpp b/examples/widgets/widgets/charactermap/characterwidget.cpp
index 41406b7fb4..422177ffa8 100644
--- a/examples/widgets/widgets/charactermap/characterwidget.cpp
+++ b/examples/widgets/widgets/charactermap/characterwidget.cpp
@@ -120,14 +120,14 @@ QSize CharacterWidget::sizeHint() const
//! [4]
void CharacterWidget::mouseMoveEvent(QMouseEvent *event)
{
- QPoint widgetPosition = mapFromGlobal(event->globalPos());
+ QPoint widgetPosition = mapFromGlobal(event->globalPosition().toPoint());
uint key = (widgetPosition.y() / squareSize) * columns + widgetPosition.x() / squareSize;
QString text = QString::fromLatin1("<p>Character: <span style=\"font-size: 24pt; font-family: %1\">").arg(displayFont.family())
+ QChar(key)
+ QString::fromLatin1("</span><p>Value: 0x")
+ QString::number(key, 16);
- QToolTip::showText(event->globalPos(), text, this);
+ QToolTip::showText(event->globalPosition().toPoint(), text, this);
}
//! [4]
@@ -135,7 +135,7 @@ void CharacterWidget::mouseMoveEvent(QMouseEvent *event)
void CharacterWidget::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
- lastKey = (event->y() / squareSize) * columns + event->x() / squareSize;
+ lastKey = (event->position().toPoint().y() / squareSize) * columns + event->position().toPoint().x() / squareSize;
if (QChar(lastKey).category() != QChar::Other_NotAssigned)
emit characterSelected(QString(QChar(lastKey)));
update();
diff --git a/examples/widgets/widgets/scribble/scribblearea.cpp b/examples/widgets/widgets/scribble/scribblearea.cpp
index d3937f90d8..2ac293d55a 100644
--- a/examples/widgets/widgets/scribble/scribblearea.cpp
+++ b/examples/widgets/widgets/scribble/scribblearea.cpp
@@ -132,7 +132,7 @@ void ScribbleArea::mousePressEvent(QMouseEvent *event)
//! [11] //! [12]
{
if (event->button() == Qt::LeftButton) {
- lastPoint = event->pos();
+ lastPoint = event->position().toPoint();
scribbling = true;
}
}
@@ -140,13 +140,13 @@ void ScribbleArea::mousePressEvent(QMouseEvent *event)
void ScribbleArea::mouseMoveEvent(QMouseEvent *event)
{
if ((event->buttons() & Qt::LeftButton) && scribbling)
- drawLineTo(event->pos());
+ drawLineTo(event->position().toPoint());
}
void ScribbleArea::mouseReleaseEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton && scribbling) {
- drawLineTo(event->pos());
+ drawLineTo(event->position().toPoint());
scribbling = false;
}
}
diff --git a/examples/widgets/widgets/shapedclock/shapedclock.cpp b/examples/widgets/widgets/shapedclock/shapedclock.cpp
index 673d1a218f..343ad7c43c 100644
--- a/examples/widgets/widgets/shapedclock/shapedclock.cpp
+++ b/examples/widgets/widgets/shapedclock/shapedclock.cpp
@@ -82,7 +82,7 @@ ShapedClock::ShapedClock(QWidget *parent)
void ShapedClock::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
- dragPosition = event->globalPos() - frameGeometry().topLeft();
+ dragPosition = event->globalPosition().toPoint() - frameGeometry().topLeft();
event->accept();
}
}
@@ -92,7 +92,7 @@ void ShapedClock::mousePressEvent(QMouseEvent *event)
void ShapedClock::mouseMoveEvent(QMouseEvent *event)
{
if (event->buttons() & Qt::LeftButton) {
- move(event->globalPos() - dragPosition);
+ move(event->globalPosition().toPoint() - dragPosition);
event->accept();
}
}
diff --git a/examples/widgets/widgets/tablet/tabletcanvas.cpp b/examples/widgets/widgets/tablet/tabletcanvas.cpp
index 90a5017500..f3f2b0cac6 100644
--- a/examples/widgets/widgets/tablet/tabletcanvas.cpp
+++ b/examples/widgets/widgets/tablet/tabletcanvas.cpp
@@ -99,7 +99,7 @@ void TabletCanvas::tabletEvent(QTabletEvent *event)
case QEvent::TabletPress:
if (!m_deviceDown) {
m_deviceDown = true;
- lastPoint.pos = event->posF();
+ lastPoint.pos = event->position();
lastPoint.pressure = event->pressure();
lastPoint.rotation = event->rotation();
}
@@ -113,7 +113,7 @@ void TabletCanvas::tabletEvent(QTabletEvent *event)
updateBrush(event);
QPainter painter(&m_pixmap);
paintPixmap(painter, event);
- lastPoint.pos = event->posF();
+ lastPoint.pos = event->position();
lastPoint.pressure = event->pressure();
lastPoint.rotation = event->rotation();
}
@@ -173,8 +173,8 @@ void TabletCanvas::paintPixmap(QPainter &painter, QTabletEvent *event)
grad.setColorAt(0.5, Qt::transparent);
painter.setBrush(grad);
qreal radius = grad.radius();
- painter.drawEllipse(event->posF(), radius, radius);
- update(QRect(event->pos() - QPoint(radius, radius), QSize(radius * 2, radius * 2)));
+ painter.drawEllipse(event->position(), radius, radius);
+ update(QRect(event->position().toPoint() - QPoint(radius, radius), QSize(radius * 2, radius * 2)));
}
break;
case QTabletEvent::RotationStylus:
@@ -191,8 +191,8 @@ void TabletCanvas::paintPixmap(QPainter &painter, QTabletEvent *event)
halfWidth = m_pen.widthF();
brushAdjust = QPointF(qSin(qDegreesToRadians(-event->rotation())) * halfWidth,
qCos(qDegreesToRadians(-event->rotation())) * halfWidth);
- poly << event->posF() - brushAdjust;
- poly << event->posF() + brushAdjust;
+ poly << event->position() - brushAdjust;
+ poly << event->position() + brushAdjust;
painter.drawConvexPolygon(poly);
update(poly.boundingRect().toRect());
}
@@ -223,8 +223,8 @@ void TabletCanvas::paintPixmap(QPainter &painter, QTabletEvent *event)
Q_FALLTHROUGH();
case QTabletEvent::Stylus:
painter.setPen(m_pen);
- painter.drawLine(lastPoint.pos, event->posF());
- update(QRect(lastPoint.pos.toPoint(), event->pos()).normalized()
+ painter.drawLine(lastPoint.pos, event->position());
+ update(QRect(lastPoint.pos.toPoint(), event->position().toPoint()).normalized()
.adjusted(-maxPenRadius, -maxPenRadius, maxPenRadius, maxPenRadius));
break;
}
diff --git a/examples/widgets/widgets/tooltips/sortingbox.cpp b/examples/widgets/widgets/tooltips/sortingbox.cpp
index d06fbe1756..d993b098b2 100644
--- a/examples/widgets/widgets/tooltips/sortingbox.cpp
+++ b/examples/widgets/widgets/tooltips/sortingbox.cpp
@@ -159,10 +159,10 @@ void SortingBox::paintEvent(QPaintEvent * /* event */)
void SortingBox::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
- int index = itemAt(event->pos());
+ int index = itemAt(event->position().toPoint());
if (index != -1) {
itemInMotion = &shapeItems[index];
- previousPosition = event->pos();
+ previousPosition = event->position().toPoint();
shapeItems.move(index, shapeItems.size() - 1);
update();
}
@@ -174,7 +174,7 @@ void SortingBox::mousePressEvent(QMouseEvent *event)
void SortingBox::mouseMoveEvent(QMouseEvent *event)
{
if ((event->buttons() & Qt::LeftButton) && itemInMotion)
- moveItemTo(event->pos());
+ moveItemTo(event->position().toPoint());
}
//! [12]
@@ -182,7 +182,7 @@ void SortingBox::mouseMoveEvent(QMouseEvent *event)
void SortingBox::mouseReleaseEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton && itemInMotion) {
- moveItemTo(event->pos());
+ moveItemTo(event->position().toPoint());
itemInMotion = nullptr;
}
}