Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Nameclash between QtQuick.Window and Qt3D.Window
Forum Update on Monday, May 27th 2025

Nameclash between QtQuick.Window and Qt3D.Window

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
7 Posts 4 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    axeljaeger17
    wrote on last edited by axeljaeger17
    #1

    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
    https://code.woboq.org/qt5/qt3d/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp.html
    (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

    1 Reply Last reply
    0
    • IntruderExcluderI Offline
      IntruderExcluderI Offline
      IntruderExcluder
      wrote on last edited by
      #2

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

      M 1 Reply Last reply
      3
      • A Offline
        A Offline
        axeljaeger17
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

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

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • A Offline
            A Offline
            axeljaeger17
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              axeljaeger17
              wrote on last edited by
              #6

              https://bugreports.qt.io/browse/QTBUG-77448

              1 Reply Last reply
              0
              • IntruderExcluderI IntruderExcluder

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

                M Offline
                M Offline
                MoBe
                wrote on last edited by
                #7

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

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved