Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-95377

Ignore missing Loader sourceComponent

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 6.1.2
    • None
    • Linux/X11

    Description

      Given this `wat.qml` file:

      import QtQuick
      Item {
      	Column {
      		Loader { sourceComponent:foo }
      		Loader { sourceComponent:undefined }
      		Loader { sourceComponent:bar }
      		Loader { sourceComponent:bar ?? undefined}
      	}
      	Component {
      		id: foo
      		Item {}
      	}
      }
      

      I get this with Qt 6.1.2:

      $ qml wat.qml
      wat.qml:6: ReferenceError: bar is not defined
      wat.qml:7: ReferenceError: bar is not defined
      

      As line 5 is not an error, is the error for line 7 a bug? (And should not be an error?)

      If undefined is a problem, could we use null or something else to ignore the error when bar is (by choice) not defined? (FWIW, my app works as intended, even with this error, so i would just want to not see the error;P)

      PS. My use-case is that BaseItem has some default UI (AKA QML Items and "layouts") and somewhere in-between is a Loader for bar, and the "extender" (do we call them that?) of BaseItem can choose to implement bar or not. (If there's an easier way to implement such feature, let me know)

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            oskude Osku Schmidt
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes