Pyside/PyQt - Attach QWidget to QGraphicsItem


#1

Has anyone been able to attach an standard QWidget to a QGraphicsItem, say a QSpinBox to modify a float value that the QGraphicsItem is representing?
I know it is possible to add a QWidget to a QGraphicsScene but I want to attach it to an Item in my Scene, rather than the scene itself.

Thanks muchly in advance.


#2

I’m not sure QGraphicsItem supports that directly unless you paint it in yourself. I think what you’re looking for if you want to display widgets is an inheritor called QGraphicsWidget. Then you can just add it as a child of your custom QGraphicsItem. http://doc.qt.io/qt-5/qgraphicswidget.html