Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

difference between QGraphicProxyWidget and QGraphicWidget



  • As mentioned in the Title i don't understand the difference Between this Widgets ,and when should i use one instead of the other.
    thanks



  • @aymen_ladiff Could you explain that you do not understand, the documentation is very clear. QGraphicsProxyWidget is a QGraphicsWidget, that is, the former is a specialized version that allows a QWidget to be easily embedded in a scene.



  • QGraphicsProxyWidget is for embedding an existing widget in a graphics scene. Use QGraphicsProxyWidget::setWidget() to specify the widget.

    QGraphicsScene scene;
    QTreeView treeView;
    QGraphicsProxyWidget proxy;
    proxy.setWidget(treeView);
    scene.addItem(&proxy);
    

    QGraphicsWidget is QGraphicsProxyWidget's base class. It can also be used as a base class for implementing a new widget with paintEvent(), etc overridden, or with a layout and children widgets.



  • @jeremy_k then so , if i will use a existing Widget i use QGraphicsProxyWidget and if i will make a new Widget by implementing the PaintEvent ,i use QGraphicsWidget ?



  • @aymen_ladiff Actually I simplify the rule: If you only want to embed a QWidget then only use a QGraphicsProxyWidget.


Log in to reply