From a061a646429c6e9d695458fc0ecb0021a30e12ee Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 4 Jun 2020 18:07:06 +0200 Subject: 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 --- .../widgets/draganddrop/draggableicons/dragwidget.cpp | 8 ++++---- .../widgets/draganddrop/draggabletext/dragwidget.cpp | 6 +++--- .../widgets/draganddrop/fridgemagnets/dragwidget.cpp | 8 ++++---- examples/widgets/draganddrop/puzzle/puzzlewidget.cpp | 16 ++++++++-------- 4 files changed, 19 insertions(+), 19 deletions(-) (limited to 'examples/widgets/draganddrop') diff --git a/examples/widgets/draganddrop/draggableicons/dragwidget.cpp b/examples/widgets/draganddrop/draggableicons/dragwidget.cpp index 00671dcf7e..1b3774db4f 100644 --- a/examples/widgets/draganddrop/draggableicons/dragwidget.cpp +++ b/examples/widgets/draganddrop/draggableicons/dragwidget.cpp @@ -120,7 +120,7 @@ void DragWidget::dropEvent(QDropEvent *event) QLabel *newIcon = new QLabel(this); newIcon->setPixmap(pixmap); - newIcon->move(event->pos() - offset); + newIcon->move(event->position().toPoint() - offset); newIcon->show(); newIcon->setAttribute(Qt::WA_DeleteOnClose); @@ -138,7 +138,7 @@ void DragWidget::dropEvent(QDropEvent *event) //! [1] void DragWidget::mousePressEvent(QMouseEvent *event) { - QLabel *child = static_cast(childAt(event->pos())); + QLabel *child = static_cast(childAt(event->position().toPoint())); if (!child) return; @@ -146,7 +146,7 @@ void DragWidget::mousePressEvent(QMouseEvent *event) QByteArray itemData; QDataStream dataStream(&itemData, QIODevice::WriteOnly); - dataStream << pixmap << QPoint(event->pos() - child->pos()); + dataStream << pixmap << QPoint(event->position().toPoint() - child->pos()); //! [1] //! [2] @@ -158,7 +158,7 @@ void DragWidget::mousePressEvent(QMouseEvent *event) QDrag *drag = new QDrag(this); drag->setMimeData(mimeData); drag->setPixmap(pixmap); - drag->setHotSpot(event->pos() - child->pos()); + drag->setHotSpot(event->position().toPoint() - child->pos()); //! [3] QPixmap tempPixmap = pixmap; diff --git a/examples/widgets/draganddrop/draggabletext/dragwidget.cpp b/examples/widgets/draganddrop/draggabletext/dragwidget.cpp index 4a430ebf56..1f1889c7cf 100644 --- a/examples/widgets/draganddrop/draggabletext/dragwidget.cpp +++ b/examples/widgets/draganddrop/draggabletext/dragwidget.cpp @@ -114,7 +114,7 @@ void DragWidget::dropEvent(QDropEvent *event) const QMimeData *mime = event->mimeData(); QStringList pieces = mime->text().split(QRegularExpression(QStringLiteral("\\s+")), Qt::SkipEmptyParts); - QPoint position = event->pos(); + QPoint position = event->position().toPoint(); QPoint hotSpot; QByteArrayList hotSpotPos = mime->data(hotSpotMimeDataKey()).split(' '); @@ -149,11 +149,11 @@ void DragWidget::dropEvent(QDropEvent *event) void DragWidget::mousePressEvent(QMouseEvent *event) { - QLabel *child = qobject_cast(childAt(event->pos())); + QLabel *child = qobject_cast(childAt(event->position().toPoint())); if (!child) return; - QPoint hotSpot = event->pos() - child->pos(); + QPoint hotSpot = event->position().toPoint() - child->pos(); QMimeData *mimeData = new QMimeData; mimeData->setText(child->text()); diff --git a/examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp b/examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp index a02b1cb42a..14e8a1a879 100644 --- a/examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp +++ b/examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp @@ -151,7 +151,7 @@ void DragWidget::dropEvent(QDropEvent *event) //! [10] //! [11] DragLabel *newLabel = new DragLabel(text, this); - newLabel->move(event->pos() - offset); + newLabel->move(event->position().toPoint() - offset); newLabel->show(); newLabel->setAttribute(Qt::WA_DeleteOnClose); @@ -165,7 +165,7 @@ void DragWidget::dropEvent(QDropEvent *event) } else if (event->mimeData()->hasText()) { QStringList pieces = event->mimeData()->text().split( QRegularExpression(QStringLiteral("\\s+")), Qt::SkipEmptyParts); - QPoint position = event->pos(); + QPoint position = event->position().toPoint(); for (const QString &piece : pieces) { DragLabel *newLabel = new DragLabel(piece, this); @@ -188,11 +188,11 @@ void DragWidget::mousePressEvent(QMouseEvent *event) { //! [13] //! [14] - DragLabel *child = static_cast(childAt(event->pos())); + DragLabel *child = static_cast(childAt(event->position().toPoint())); if (!child) return; - QPoint hotSpot = event->pos() - child->pos(); + QPoint hotSpot = event->position().toPoint() - child->pos(); QByteArray itemData; QDataStream dataStream(&itemData, QIODevice::WriteOnly); diff --git a/examples/widgets/draganddrop/puzzle/puzzlewidget.cpp b/examples/widgets/draganddrop/puzzle/puzzlewidget.cpp index 72f2662bce..06dda9c29f 100644 --- a/examples/widgets/draganddrop/puzzle/puzzlewidget.cpp +++ b/examples/widgets/draganddrop/puzzle/puzzlewidget.cpp @@ -90,12 +90,12 @@ void PuzzleWidget::dragLeaveEvent(QDragLeaveEvent *event) void PuzzleWidget::dragMoveEvent(QDragMoveEvent *event) { - QRect updateRect = highlightedRect.united(targetSquare(event->pos())); + QRect updateRect = highlightedRect.united(targetSquare(event->position().toPoint())); if (event->mimeData()->hasFormat(PiecesList::puzzleMimeType()) - && findPiece(targetSquare(event->pos())) == -1) { + && findPiece(targetSquare(event->position().toPoint())) == -1) { - highlightedRect = targetSquare(event->pos()); + highlightedRect = targetSquare(event->position().toPoint()); event->setDropAction(Qt::MoveAction); event->accept(); } else { @@ -109,12 +109,12 @@ void PuzzleWidget::dragMoveEvent(QDragMoveEvent *event) void PuzzleWidget::dropEvent(QDropEvent *event) { if (event->mimeData()->hasFormat(PiecesList::puzzleMimeType()) - && findPiece(targetSquare(event->pos())) == -1) { + && findPiece(targetSquare(event->position().toPoint())) == -1) { QByteArray pieceData = event->mimeData()->data(PiecesList::puzzleMimeType()); QDataStream dataStream(&pieceData, QIODevice::ReadOnly); Piece piece; - piece.rect = targetSquare(event->pos()); + piece.rect = targetSquare(event->position().toPoint()); dataStream >> piece.pixmap >> piece.location; pieces.append(piece); @@ -147,7 +147,7 @@ int PuzzleWidget::findPiece(const QRect &pieceRect) const void PuzzleWidget::mousePressEvent(QMouseEvent *event) { - QRect square = targetSquare(event->pos()); + QRect square = targetSquare(event->position().toPoint()); const int found = findPiece(square); if (found == -1) @@ -170,12 +170,12 @@ void PuzzleWidget::mousePressEvent(QMouseEvent *event) QDrag *drag = new QDrag(this); drag->setMimeData(mimeData); - drag->setHotSpot(event->pos() - square.topLeft()); + drag->setHotSpot(event->position().toPoint() - square.topLeft()); drag->setPixmap(piece.pixmap); if (drag->exec(Qt::MoveAction) != Qt::MoveAction) { pieces.insert(found, piece); - update(targetSquare(event->pos())); + update(targetSquare(event->position().toPoint())); if (piece.location == square.topLeft() / pieceSize()) inPlace++; -- cgit v1.2.3