Does a simple method exist to select part of a QGraphicsItem (like for a selection, with a dashed border for example), despite its position in the QGraphicsScene
I've found QGraphicsItem::ItemIsSelectable
but it doesn't help me much.
Thx
You can't select a part of QGraphicsItem. You can select whole item. Usualy it will draw a dashed rectangle around itself when selected.
You can select item by:
QGraphicsItem::setSelected
or
QGraphicsScene::setSelectionArea
Do you want to select it when you're clicking on it? If yes, you can override the mousePressEvent(QGraphicsSceneMouseEvent event)
listener for this item, and use setSelected()
. In Java (sorry about it), it would be something like:
@Override
public void mousePressEvent (QGraphicsSceneMouseEvent event) {
if (event.button() == Qt.MouseButton.LeftButton) {
this.setSelected(true);
}
}
If you want to select it with a left button of course. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With