[英]Show Qt3D stuff inside QWidget in Qt5
So I felt all warm and fuzzy inside afterreading that Qt3D has re-emerged in a v2.0 and is in fact becoming a part of Qt5 soon and that parts of it is already available for testing as a tech preview.因此,当我读到Qt3D重新出现在v2.0 中并且实际上很快成为Qt5的一部分并且其中的一部分已经可以作为技术预览进行测试后,我内心感到温暖和模糊。
I set out with a simple plan, I would have Qt3D working inside a widget in my existing C++/widgets based application.我制定了一个简单的计划,我将让Qt3D在我现有的基于C++/widgets的应用程序中的一个小部件中工作。 However the only example I could find that shows how to use Qt3D from C++ is calledbasicshapes-cpp , and it shows some shapes rendered in a separate OpenGL/Qt3D prepared
window
(class that extends QWindow
) as opposed from a QWidget
.然而,我能找到的唯一一个展示如何从C++使用Qt3D 的示例称为basicshapes-cpp ,它显示了在单独的 OpenGL/Qt3D 准备好的
window
(扩展QWindow
类)中呈现的一些形状,而不是QWidget
。
Now I read about the role of QWindow
vs. QWidget
and how it all hangs together neatly, but I am still struggling to understand how I can port the Qt3D code from the basicshapes-cpp
program to run inside a QWidget
.现在我读到了
QWindow
与QWidget
的作用以及QWindow
如何巧妙地结合在一起,但我仍在努力理解如何将Qt3D代码从basicshapes-cpp
程序basicshapes-cpp
到QWidget
运行。 What are the basic steps that need to observed?需要观察的基本步骤是什么?
This extraction of this post shows how it works:这种提取这篇文章显示了它是如何工作:
#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
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.