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

QML inline components from other files are not recognized in the editor

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • Qt Creator 8.0.2
    • Quick / QML Support
    • None

    Description

      In Qt Creator's QML code editor, referencing inline components defined in another QML file does not work properly. It seems that they are not recognized at all. Steps to reproduce:

      1. New project > Application (Qt) > Qt Quick Application
      2. Build system - qmake (probably not important, but that's what I use)
      3. All other options default
      4. New File > Qt > QML File (Qt Quick 2) > Images.qml > Add to qml.qrc
      Prefix: /
      5. Images.qml contents:

      import QtQuick 2.15
      
      Item {
      	component LabeledImage: Column {
      		property alias source: image.source
      		property alias caption: text.text
      		Image {
      			id: image
      			width: 50
      			height: 50
      		}
      		Text {
      			id: text
      			font.bold: true
      		}
      	}
      }
      

      6. Go back to main.qml and try using Images.LabeledImage

      import QtQuick 2.15
      import QtQuick.Window 2.15
      
      Window {
      	Images.LabeledImage {
      		caption: "Caption"
      	}
      
      	width: 640
      	height: 480
      	visible: true
      	title: qsTr("Hello World")
      }
      

      Expected Behavior: Images.LabeledImage is recognized and autocompletion for its properties is available.
      Observed Behavior: Qt Creator shows an error "Unknown Component. (M300)", and autocompletion is not available. Building and running the project works as expected and the LabeledImage is shown, so the issue is just in the code editor.

      Inline components defined in the same file are recognized and work without issues.

      Using Qt Creator 8.0.2.

      Attachments

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

        Activity

          People

            qtqmlteam Qt Qml Team User
            12bit_integer Godkiller Hellguy
            Votes:
            4 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes