In this case using QGraphicsView is the solution, if you want to keep things simpler.
You can customize painting and the framework has builtin item interaction.
In this case using QGraphicsView is the solution, if you want to keep things simpler.
You can customize painting and the framework has builtin item interaction.
Thanks again,
Just looking at QGraphicsView and QGraphicsScene now. I take it my items would be of QGraphicsItem and I override the paint event to draw my item?
Qt Code:
{ { // do whatever painter->drawRoundRect( 10, 10, 20, 20 ); } };To copy to clipboard, switch view to plain text mode
May even derive from QGraphicsPolygonItem...
How do I know when a user clicks on one of the GraphicItems, is this part of the QGraphicsScene - i.e. mousePressEvent?
Regards,
Steve
You have to override the item's mousePressEvent.
Take a look at the protected functions in the QGraphicsItem class.
Many thanks for your help Marcel,
Going to have a derived class from QGraphicsItem, override paint and boundingRect and the mousePressEvent. I did notice that it would also be possible to create a slot in the main window which could be emited from the scene when an item is selected ( capture the mouseEvent within the scene ) - although I think just overriding the mousePressEvent within the subclassed QGraphicsItem class seems simpler.
Regards,
Steve
Bookmarks