7

特定の点がの輪郭上または輪郭(x, y)近くにあるかどうかをテストしようとしています。QGraphicsPathItem

使用するQGraphicsItem.contains().collidesWithItem() / Path()しないか:ポイントがパスの内部の領域内に含まれている場合もTrueを返しますが、アウトライン上のポイントのみをテストします。どうすればそれを達成できますか?

4

1 に答える 1

2

質問を投稿した後、私は次の解決策を見つけました:

    path = QPainterPath(...)   # Path we are testing against
    point = QPointF(...)       # Current position

    stroker = QPainterPathStroker()
    stroker.setWidth(10)        # Distance which we consider "on" the path 
    stroke = stroker.createStroke(path)

    if stroke.contains(point):
        # point is on path
于 2010-02-06T22:42:38.263 に答える