1、绘图可以简单地理解成有一个视图GraphicsView,在这个视图中可以加载多个场景QGraphicsScene,多个场景中加载多个QGraphicsItem对象;
2、QGraphicsProxyWidget的作用是为在场景中嵌入QWidget,例如QPushButton, QFontComboBox,QFileDialog等,提供一个代理层,QGraphicsProxyWidget也是一个QGraphicsItem对象;
3、QGLWidget是一个用来渲染OpenGL图形的控件,它将OpenGL图形集成到一个Qt应用中,用法是GraphicsView.setViewport(QGLWidget)即可;
4、如实例所示,创建一个场景类Scene,继承自QGraphicsScene;
Scene.h中:
class Scene : public QGraphicsScene
{
Q_OBJECT
public:
Scene();
~Scene();
};
Scene.cpp中:
Scene::Scene()
{
setSceneRect(0,0,600,400);setBackgroundBrush(Qt::blue);
}
Scene::~Scene()
{
}
5、如实例所示,创建一个控件代理类ProxyWidget,继承自QGraphicsProxyWidget;
ProxyWidget.h中:
class ProxyWidget : public QGraphicsProxyWidget
{
public:
ProxyWidget();
protected:
void resizeEvent(QGraphicsSceneResizeEvent *event) override;
voi