How do I mix QT3D with normal QTGui/QTWidget code?
-
So, I can't seem to find an answer to this anywhere.
I'm trying to write a game (currently only an audio game but maybe in the future I'll expand it with graphics) which uses QTGui as the UI and Qt3D for input, logic, etc., where the UI doesn't consume input for itself. I'm trying to avoid QML, but the QT documentation is full of it. Examples that I've found use
Qt3DExtras::QT3DWindow
, which appears to be an undocumented class. So I don't know how to:- Create a normal QT UI
- Create a 3D widget within that UI where input/logic/etc. occurs
Or, alternatively:
- Create a full 3D window
- Receive input, do logic, etc., but then when I need a UI, I can just ask QT to display me a new window.
Ideas?
-
@Ethindp https://doc.qt.io/qt-6/qt3d-examples.html
in the following example:
https://code.qt.io/cgit/qt/qt3d.git/tree/examples/qt3d/basicshapes-cpp/main.cpp?h=6.5Qt3DExtras::Qt3DWindow *view = new Qt3DExtras::Qt3DWindow(); view->defaultFrameGraph()->setClearColor(QColor(QRgb(0x4d4d4f))); QWidget *container = QWidget::createWindowContainer(view); QSize screenSize = view->screen()->size();
you can see that a container can be created to wrap Qt3DExtras::Qt3DWindow and can be put into any layout for example inside a qt window.
-
Hello,
To combine Qt3D and QtGui effectively, create separate components for 3D and 2D elements. Use Qt3D's input system for 3D interactions and Qt's event handling for GUI elements. Prioritize input based on focus. Communicate between components using signals and slots. Consider performance implications and thorough testing.