I have added a widget to a graphic scene (QGraphicScene) through a QGraphicsProxyWidget. The problem is that when I select the item it's selected, but the selection border is not visible.
Here is the code:
QDial *dial= new QDial(); // Widget
dial->setGeometry(3,3,100,100);// setting offset for graphicswidget and widget
QGraphicsWidget *ParentWidget = new QGraphicsWidget();// created to move and select on scene
ParentWidget->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
Scene->addItem(ParentWidget); // adding to scene
QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget();// adding normal widget through this one
proxy->setWidget( DialBox );
proxy->setParentItem(ParentWidget);
Here is the output:
How could I fix this?
Cause
QGraphicsWidget does not paint anything (including a selection rectangle), as seen from the source code:
QGraphicsRectItem, however, does (see the source code):
Solution
My solution would be to use QGraphicsRectItem instead of QGraphicsWidget as a handle to select/move the dial like this:
This code produces the following result:
Click the dark gray area around the dial widget to select/move it or the widget itself in order to interact with it.