Here's the reference drawing I obtained.
path.moveTo(0, 0);
path.lineTo(0, -20);
path.lineTo(40, -20);
path.lineTo(40, -95);
int testX = 4;
int testY = -17;
QRectF rect
(testX
- 2, testY
- 2,
4,
4);
bool intersects = path.intersects(rect);
qDebug() << "Intersects?" << ((intersects) ? "true" : "false");
qDebug() << "Rect: x =" << rect.x() << "| y =" << rect.y() << "| w =" << rect.width() << "| h =" << rect.height();
scene->addPath(path);
scene->addRect(rect);
QPainterPath path;
path.moveTo(0, 0);
path.lineTo(0, -20);
path.lineTo(40, -20);
path.lineTo(40, -95);
int testX = 4;
int testY = -17;
QRectF rect(testX - 2, testY - 2, 4, 4);
bool intersects = path.intersects(rect);
qDebug() << "Intersects?" << ((intersects) ? "true" : "false");
qDebug() << "Rect: x =" << rect.x() << "| y =" << rect.y() << "| w =" << rect.width() << "| h =" << rect.height();
scene->addPath(path);
scene->addRect(rect);
To copy to clipboard, switch view to plain text mode
Intersects? true
Rect: x = 2 | y = -19 | w = 4 | h = 4
They don't intersect in the drawing, do they?
Bookmarks