V
V
Vitaly2014-06-19 23:04:00
Qt
Vitaly, 2014-06-19 23:04:00

How to make it possible to select and grab invisible (fully transparent) objects in QGraphicsScene?


There is an application created on the basis of Qt 5.3.0 not hidden, but having a completely transparent picture. The goal is to make it possible to select or grab such objects with the mouse. Since QGraphicsScene only selects objects based on their shape (visible pixels), where do I need to set a flag so that I can select an object based on its size rectangle, even if it has a completely transparent image?
There is an idea to first check each pixel for transparency during initialization and reduce the transparency level by microns in order to make the object at least a little visible for the mouse and selection zone, but this can slow down the initialization process, especially if the total of unique images is about 1000-2000. I suppose that there should be a flag for QGraphicsView or QGraphicsScene so that I can grab such invisible objects with the mouse.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaliy, 2014-06-20
@Wohlstand

Phew, I found the solution myself:
it's the QGraphicsPixmapItem themselves. Everything is elementary, just set the form mode to "BoundingRectShape"

Item->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question