From f5eda09a639715036d48a60078e6a379ec151f94 Mon Sep 17 00:00:00 2001 From: Tang Haixiang Date: Fri, 29 Oct 2021 11:40:46 +0800 Subject: Modify the target Square in the puzzle targetSquare judges which square the position falls in. The point scaling calculation method should not be used. The return value of QPoint operator/ will be rounded up. Modified to separate the x and y of position to calculate. Fixes: QTBUG-81842 Change-Id: I70375185a78ba47efe01be3fd490e0fb0f456e17 Reviewed-by: Shawn Rutledge --- examples/widgets/itemviews/puzzle/puzzlewidget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'examples/widgets/itemviews') diff --git a/examples/widgets/itemviews/puzzle/puzzlewidget.cpp b/examples/widgets/itemviews/puzzle/puzzlewidget.cpp index 2c60d28946..e5e0192c96 100644 --- a/examples/widgets/itemviews/puzzle/puzzlewidget.cpp +++ b/examples/widgets/itemviews/puzzle/puzzlewidget.cpp @@ -195,8 +195,8 @@ void PuzzleWidget::paintEvent(QPaintEvent *event) const QRect PuzzleWidget::targetSquare(const QPoint &position) const { - return QRect(position / pieceSize() * pieceSize(), - QSize(pieceSize(), pieceSize())); + QPoint topLeft = QPoint(position.x() / pieceSize(), position.y() / pieceSize()) * pieceSize(); + return QRect(topLeft, QSize(pieceSize(), pieceSize())); } int PuzzleWidget::pieceSize() const -- cgit v1.2.3