Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-112605 Make StackView compilable by qmlsc
  3. QTBUG-112604

StackView: 2-arg versions of get() and find() cannot be compiled by qmlsc

    XMLWordPrintable

Details

    • a1569fa21 (dev), f4c8edf20 (6.5)

    Description

      Code

      import QtQuick
      import QtQuick.Controls.Basic
      
      Window {
          width: 640
          height: 480
          visible: true
      
          StackView {
              id: stack
          }
      
          function get1(): void { // OK
              stack.get(0)
          }
          function get2(): void { // Error
              stack.get(0, StackView.DontLoad)
          }
          function find2(): void { // Error
               stack.find(function(item) {
                   return false;
               }, StackView.DontLoad)
          }
      }
      

       

      Compiler output

      Warning: main.qml:17:15: Could not compile function get2: No matching override found. Candidates:
      Function expects 1 arguments, but 2 were provided
      type LoadBehavior for argument 1 cannot be resolved [compiler]
              stack.get(0, StackView.DontLoad)
                    ^^^
      Warning: main.qml:20:10: Could not compile function find2: No matching override found. Candidates:
      Function expects 1 arguments, but 2 were provided
      type LoadBehavior for argument 1 cannot be resolved [compiler]
               stack.find(function(item) {
                     ^^^^
      

       

      Analysis
      This occurs because the signatures of the invokable functions do not use fully-qualified types (see https://github.com/qt/qtdeclarative/blob/v6.5.0/src/quicktemplates/qquickstackview_p.h#L93-L94 )

      clazy-standalone v1.11 with LLVM v15.0.0 (from Qt Creator 9.0.1) produces the following warnings:

      warning: invokable arguments need to be fully-qualified (QQuickStackView::LoadBehavior instead of LoadBehavior) [-Wclazy-fully-qualified-moc-types]
          Q_INVOKABLE QQuickItem *get(int index, LoadBehavior behavior = DontLoad);
                      ^
      warning: invokable arguments need to be fully-qualified (QQuickStackView::LoadBehavior instead of LoadBehavior) [-Wclazy-fully-qualified-moc-types]
          Q_INVOKABLE QQuickItem *find(const QJSValue &callback, LoadBehavior behavior = DontLoad);
                      ^
      

      Attachments

        Issue Links

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

          Activity

            People

              skoh-qt Sze Howe Koh
              skoh-qt Sze Howe Koh
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes