Gerd
Gerd

Reputation: 73

Qt: display qgraphicsitem in a widget

I got a QGraphicsScene that contains QGraphicsItems. On clicking such an item I open a dialog. I now want the item to be displayed in an area of the dialog.

I tried a QGraphicsView (in the dialog) and "pointed" it to the item which works allmost perfectly. The problem is, that it is possible to click the item in the dialog which would open a new dialog.

So my question: is there a easy way to tell QGraphicsView to ignore any input events? If not, is there a easy way to display a QGraphicsItem within a widget?

Upvotes: 0

Views: 642

Answers (2)

Gerd
Gerd

Reputation: 73

I am feeling so stupid...

QGraphicsView::setInteractive(false) did the trick. I am still able to move the icon with the mouse wheel but this can probably be avoided by restricting the scene rect with setSceneRect()

Upvotes: 1

TheDarkKnight
TheDarkKnight

Reputation: 27611

You can install an event filter, on the QGraphicsView, which ignores input events. The Qt documentation states:

In your reimplementation of this function, if you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.

Upvotes: 0

Related Questions