Important: Please read the Qt Code of Conduct -

Nameclash between QtQuick.Window and Qt3D.Window

  • Hello,
    consider the following piece of QML code:

    import QtQuick 2.13
    import QtQuick.Window 2.13
    import QtQuick.Scene3D 2.0
    import Qt3D.Render 2.0
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")

    Running this piece of code results in a runtime error:

    qrc:/main.qml:9 Only for assigning window surface property

    So what happens? Googling the error message results in the source code of qt3dquick3drenderplugin.cpp
    (Line 164) where the plugin registers QWindow as Window that us an uncreatable type:

    qmlRegisterUncreatableType<QWindow>(uri, 2, 0, "Window", "Only for assigning window surface property");

    This results in a nameclash of QtQuick.Window beeing shadowed by this new Window that is actually a QWindow. How to use QtQuick.Window together with Qt3DRenderer in one QML file? I tried a QtQuick.Window as type but this does not work.

    Best regards

    Axel Jäger

  • You may write import QtQuick.Window 2.13 as W and then use W.Window { ....

  • Thank you for the answer, now I can continue with my coding. But would you consider this as a bug? I see no reason why QWindow is registered as "Window" as this verbose name is not needed, so it could be something more unique to avoid this clash.

  • Lifetime Qt Champion


    It's not a bug, you can have other libraries that reuses same class names. You see this often also in python for example.

  • Well, technically its not a bug, the behaviour is understandable, but I think it is a bad decision to name that internal class "Window". Also, the error message is not helpfull to resolve the problem without looking into the sourcecode. Further, I think it is not an exotic usecase to use both QtQuick Window and some Qt3D stuff. As both modules are part of Qt, it should not be neccassary to rename one of them. I'll report a bug and see what the trolls say.

  • @IntruderExcluder Thank you! I had the same issue and your solution worked very well.

Log in to reply