Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
2D QML as texture of Quick3D Object
I've been searching around for a while now and can't seem to find anything about this. I'd like to use 2d qml inside qt3d objects. For exemple let's have a Cube, I would like to assign a qml listview for each of its faces.
Can anyone tell me if it's possible.
QML is rendered onto a QDeclarativeView which inherits from QWidget.
That means that it has the QWidget::winId function.
That function is used in QPixmap.grabWindow.
I have not used qt3d,so I do not know how to map the generated texture.
I found this http://doc.qt.nokia.com/qt-quick3d-snapshot/qgltexture2d.html#setPixmap
This method will transform the QML view pixmap into an opengl compatible texture.
Thanks for the reply.
I'm actually using qt5 and qml 2.0 and with the new scenegraph qml items do not inherit from QWidget any longer. However I tried to use a technique similar to yours which is saving the qml in a framebufferobject and then render it as a texture on the 3d object. So far I've managed to save the qml as a framebuffer but I can't find a way to map it on the object yet.
I do not know how qt5 and qml2 scenegraph api work,but if you can use opengl,
glTexture2f will do the trick.
What I would like to do is implement qml objects that interact between qml items and qt3d items so that I can then easily use qml on 3d objects. Here is a link that discuss it, in the comments at the bottom there's an example : https://bugreports.qt-project.org/browse/QTBUG-19902?attachmentOrder=desc
Once I find a way to transmit the fbo to the target 3d object then I might use gltexture2f but I'm not there yet.
What you are trying to do is not very easy and I do not know of any easy
QMLway to do it.
You are trying to have 2D surface that respond to 2D input on 3D surface (cube in your example).
To do that, you will need to transform the 3D coordinates of the mouse to 2D coordiantes and then use those 2D coordinates in some kind of update method.
As I said, I am not aware of any easy non C++ method of doing so.
So you might just have to get native ;)