Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-11377

QtQuick Designer doesn't show UI if importing C++ class

XMLWordPrintable

      Qt Quick Designer does not show a QML component if you import an unknown module. This would be an understandable behavior if the module actually didn't exist, but it's not passable if the module does exist but comes from a C++ class.

      Example:

      • main.qml
        import QtQuick 2.0
        
        MyComponent {
          x: 0
          y: 0
          height: 200
          width: 200
        }
        
      • MyComponent.qml
        import QtQuick 2.0
        import Testing 1.0
        
        Image {
           x: 0
           y: 0
           source: "myimage.png"
        }
        
      • main.cpp
        class TestClass;
        ...
        
        QGuiApplication app(argc, argv);
        QtQuick2ApplicationViewer viewer;
        qmlRegisterType<TestClass>("Testing", 1, 0, "Test");
        viewer.setMainQmlFile(QStringLiteral("main.qml"));
        

        end of example

      If you try to edit main.qml on Qt Quick Designer, it simply doesn't show the component MyModule that should be inside it. However, if I comment the line "import Testing 1.0" on MyComponent.qml, it shows the component once again.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            mabenell Marco Benelli
            theoribeiro Theo Ribeiro
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes