简体   繁体   English

如何动态地添加一个基于QGraphicsScene的QWidget?

[英]how to dynamically add a QWidget based to QGraphicsScene?

I want to add a QWidget based class(composed by buttons and labels an so on...) to my QGraphicScene scene in a special position and respecting the graphic style of my scene.? 我想在我的QGraphicScene场景中的特殊位置添加一个基于QWidget的类(由按钮和标签组成,依此类推...),并尊重场景的图形样式。

I am using QT 4.7. 我正在使用QT 4.7。

You may use QGraphicsScene::addWidget() to add your widget to the scene and use the returned QGraphicsProxyWidget * to reposition your widget with QGraphicsItem::setPos(). 您可以使用QGraphicsScene :: addWidget()将小部件添加到场景中,并使用返回的QGraphicsProxyWidget *通过QGraphicsItem :: setPos()重新定位小部件。 Alternatively, you may look into QGraphicsWidget class. 或者,您可以查看QGraphicsWidget类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM