Unsolved Qt3D Multiple Viewports with C++
-
I would like to create multiple viewports for a C++ Qt3D a program. I’ve seen the QML example. However, I searched for a C++ method to no avail. I attempted to create 2 views:
Qt3DExtras::Qt3DWindow *view1 = new Qt3DExtras::Qt3DWindow(); Qt3DExtras::Qt3DWindow *view2 = new Qt3DExtras::Qt3DWindow();
And eventually:
View1->setRootEntity(rootEntity); view2->setRootEntity(rootEntity);
This results with only view2 displaying the scene. Is it possible to create multiple viewports for a non QML Qt3D application? Or can a root entity created in C++ be passed to a QML viewport?
-
You only need (and should only use) one 3D window. You set the root entity like you do in your example and then create a framegraph like the one on the QML example. To "activate" this framegraph you have to retrieve the QRenderSettings from the 3D window using the method
renderSettings()
(the only purpose of the render settings is holding the active framegraph) and then setting your custom framegraph by callingsetActiveFramegraph(QFramegraphNode*)
. The rootEntity in your example is the root of the objects that are to be displayed, the framegraph on the other hand specifies HOW it should be displayed.