Qt 3D示例——cube

Qt 3D官方示例

  cube的3D演示,一个纯C++的项目。虽然QML示例比较炫,但是要深入理解还是得从C++例子入手。

  从MainWidget.show入口。一步步可以跟踪到initializeGL,paintGL,resizeGL,对了解OpenGL运行流程有帮助。

  MainWidget.show---->Qwidget::show-----> setVisible(true);---> show_helper

  从show_helper中会引出一条主线

  sendPendingMoveAndResizeEvents主动触发QWidget::event事件(其中涉及到的通信机制太复杂),
    事件类型为QOpenGLWidget的resizeEvent。(d->initialize();)
    resizeEvent最终会调用到 MainWidget::initializeGL()
    resizeEvent最终会调用到 MainWidget::resizeGL()
    resizeEvent最终会调用到 MainWidget::initializeGL()

                              ---> showChildren(false);

                              ---->sendEvent(q, &showEvent);

                              ---->show_sys---> setVisible(true);(显示窗口)

                              

                            ----->sendSyntheticEnterLeave(this)

              

resizeEvent --> resizeGL --> 
initTextures中会读取png图片放在Image(750x500)中用于贴图。

    setVisible函数内部会把所有初始化搞定,继续跟进工作量太大。

    QWidget::create---->

 

  

猜你喜欢

转载自www.cnblogs.com/daiker/p/Qt3D.html