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

QML language server doesn't resolve type of "this"

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Duplicate
    • Icon: P2: Important P2: Important
    • 6.9
    • 6.8
    • QML: Tooling
    • None

      Accessing a property member in QML with the "this." prefix causes the QML language server to emit a warning similar to the following:

      Member "hoverColor" not found on type "QObject" [missing-property]

      It seems that the qmlls always treats "this" as a QObject instead of resolving it's actual type. It can be useful to use "this.<propertyName>" as it removes all ambiguity as to where the property should resolve from while being id agnostic so that if code needs to be copied to somewhere else there is no need to refactor all the ids. It is also a familliar pattern for python devs.

      It's possible to work around the issue using a direct cast but that is very verbose.

      Would it be possible for the qmlls to handle this case?

       

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

            qtqmlteam Qt Qml Team User
            haiku Ollie Dawes
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes