Selecting Multiple QGraphicsItems within a QGraphicsPolygonItem (setDragMaode(QGraphicView::RubberbandDrag))



  • I'm having trouble selecting multiple items with RubberBandDrag when inside a QGraphicsPolygonItem. The polygonItem is lower(zValue 0.1) than the target items(zValue 1.1).

    I can start the mouse drag outside the polygon and then drag it inside to select the items inside the polygonitem. However when I start the mouse drag inside the polygonitem, I can not select the items inside the polygonitem.

    Any Suggestions?



  • If the polygonItem itself is selectable, you cannot start a rubber band clicking on it. This would run counter to how single-click-selection works.



  • Thank you for you response. Do you know of a work around where I can rubber band select items inside the polygonitem?



  • The obvious solution would be to make the polygonitem non-selectable, but I guess that's not what you want.

    You could however try to reimplement sceneEvent and handle the case of a left-button click. If you ignore the event, and not forward it to your baseclass in certain cases, you should get the rubberband. Of course, the polygonitem would no longer be selected on leftclick, but you can yourself define when the item is selected, and when the rubberband is started.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.