much thanks - this is the code that works for me:
matrix.translate(value.toPointF().x(), value.toPointF().y());
polygon = matrix.map(path);
QList<QGraphicsItem*> items = scene()->items(path, Qt::IntersectsItemShape);
items.removeAll(this);
if (!items.isEmpty()) {
// Collision! Don't move.
return pos();
}
QPainterPath path = shape();
QMatrix matrix;
matrix.translate(value.toPointF().x(), value.toPointF().y());
polygon = matrix.map(path);
QList<QGraphicsItem*> items = scene()->items(path, Qt::IntersectsItemShape);
items.removeAll(this);
if (!items.isEmpty()) {
// Collision! Don't move.
return pos();
}
To copy to clipboard, switch view to plain text mode
i didn't need the mapToParent and mapToScene calls. furthermore QPainterPath doesn't have a translate-function afaics - so i used qmatrix for that...
niko
Bookmarks