Important: Please read the Qt Code of Conduct -

Using QImage as Texture in Qt3D

  • Hi,

    I was searching for a solution to load custom pixels from C++ into Qt3D as a Texture.


    1. I have a working QQuickImageProvider with URLs like "image://myImageProvider/someId" working. When I give these Urls to a Qt3D TextureImage I get an error "QTextureImage only supports local url".
    2. I tried using Scene2D and load an oldfashioned Image-Item. This does work, but I run into an error when using Scene2D in a NodeInstantiator (maybe this bug:
    3. Currently I am implementing a Qt3DRender::QTextureGenerator and Qt3DRender::QAbstractTexture. Now I think I need to use Qt private Headers to access Qt3DRender::QAbstractTexturePrivate and it's "setDataFunctor"-Method.

    Before contiuing this (quite painful) path, I wanted to ask for simpler solutions I might overlooked. Any ideas?

    Thanks in advance

  • I've got a workaround to get approach 2) working.

    A solution is, to use a repeater inside one single Scene2D in addition to the NodeInstantiator.
    I then render all needed images using an image-providers.
    NodeInstantiator uses the Scene2D as a "TextureAtlas" and cutts out the repeated images as needed.

  • I use Qt3DRender::QPaintedTextureImage to paint QImage objects onto Qt3DRender::QTexture2D from C++. But I don't know if you can access that on QML level in a convenient way.

  • @Andreas-E could you please give us a short C++ example of how you implement your idea with QTexture2D and QPaintedTextureImage in the same time ? Could help me a lot !

  • Banned

    This post is deleted!

Log in to reply