getWidgetAt/getChildAt(global position) for elements under QGraphicsProxyWidget
Hello folks,
I'm looking for a way to retrieve what widget is under position x,y including the ones inside QGraphicsProxyWidgets.
QApplication and QWidget's methods return the scene widget instead of the widget inside it.
If that's not possible.. if there's a way to post a mouse event "globally" that will reach the children widget at certain position, that would do the trick. I'm using postEvent, but I have to pass the target widget, so I have to find that widget first.
Thanks a lot for any help :)
Re: getWidgetAt/getChildAt(global position) for elements under QGraphicsProxyWidget
Hello,
I'll answer myself in case somebody needs the same thing in the future..
You map the global coordinates to the view:
Code:
QPoint relativePos
= view
->mapFromGlobal
(pos
);
Then the view local coordinates to the scene:
Code:
QPointF scenePos
= graphicsView
->mapToScene
(relativePos
);
And finally the scene pos to the GraphicsItem pos
Code:
QPointF sceneRelPos
= item
->mapFromScene
(scenePos
);
Now proxy->widget()->childAt(sceneRelPos.toPoint) will return the widget that was hit inside the proxy.
Cheers
Geovani
Re: getWidgetAt/getChildAt(global position) for elements under QGraphicsProxyWidget
Excuse me, what can we use these things to do??
Can we retrieve the position of the mouse out of the application interface??
Thanks