因此,在阅读之后,我感到内心充满了温暖和模糊,Qt3D在v2.0中重新出现,实际上很快就会成为Qt5的一部分,其中的部分已经可以作为技术预览进行测试。
我提出了一个简单的计划,让Qt3D在我现有的基于C++/小部件的应用程序中使用一个小部件。但是,我所能找到的演示如何使用Qt3D from C++的唯一示例称为基本形状-cpp,它显示了与QWidget不同的OpenGL/Qt3D准备的window (扩展QWindow的类)中呈现的一些形状。
现在我读到了QWindow与QWidget的角色,以及它是如何整齐地挂在一起的,但我仍然难以理解如何将Qt3D代码从basicshapes-cpp程序移植到QWidget中运行。需要遵守的基本步骤是什么?
发布于 2018-02-28 22:46:32
这个职位的提取显示了它是如何工作的:
#include <QObject>
#include <QWidget>
#include <Qt3DExtras/Qt3DWindow>
class Qt3DWidget
: public QWidget
{
Q_OBJECT
QWidget *container;
public:
explicit Qt3DWidget(QWidget *parent = nullptr);
};
Qt3DWidget::Qt3DWidget(QWidget *parent)
: QWidget(parent)
{
auto view = new Qt3DExtras::Qt3DWindow();
// put Qt3DWindow into a container in order to make it possible
// to handle the view inside a widget
container = createWindowContainer(view,this);
// ... further stuff goes here
}发布于 2020-09-07 10:04:32
如果有人感兴趣,我实现了一个实际的Qt3D小部件。代码可以找到这里。
https://stackoverflow.com/questions/35074830
复制相似问题