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 <shawn.rutledge@qt.io>
This commit is contained in:
parent
ace53d282d
commit
f5eda09a63
@ -199,8 +199,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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user