Unsolved QGraphicsRectItems
-
Hello,
So I am trying to visualize the pathfinding algorithms on qt. How could I make that user could select the starting point and the endpoint with his mouse on the QGraphicsRectItems and I would receive which rectangles were selected? -
Hi
You mean drag out a rect and then all QGraphicsRectItems within that area are selected ?
You can use https://doc.qt.io/qt-5/qrubberband.html
for the drag a rect effectAlternatively, the user can already select multiple objects if holding down CTRL and left-clicking.
-
@mrjj said in QGraphicsRectItems:
Hi
You mean drag out a rect and then all QGraphicsRectItems within that area are selected ?No, I mean that when a window is opened first two clicks would change QGraphcisRectItems
color and I could store information which QGraphcisRectItems were "selected" .- Opens a window
- Selects a starting point
- Selects an endpoint
And I somehow store those points
-
Hi,
You can do it from several different techniques.
For example, you can make your items selectable and use the QGraphicsScene::selectionChanged signal.
You can implement the mousePressEvent method to manage the selection yourself and also update the item colour.