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

qmltypes warning when using const in Q_INVOKABLE

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • 6.5.6, 6.5, 6.7.1, 6.8.0 FF
    • 6.5.5, 6.7.0 RC
    • QML: Compiler
    • None
    • Windows
    • d75c81639 (dev), ea76ae03f (6.7), ecd5b0edf (6.6), 69d52e41c (tqtc/lts-6.5)

    Description

      I am exposing MyType to QML via qt_add_qml_module().
      I am trying to use const with Q_INVOKABLE like so (this is just a sample code to reproduce the issue):

       

      #ifndef MYTYPE_H
      #define MYTYPE_H
      #include <QObject>
      #include <QQmlEngine>
      class MyType : public QObject
      {
          Q_OBJECT
          QML_ELEMENT
      public:
          explicit MyType(QObject *parent = nullptr)
              : QObject{parent}
          {}
          Q_INVOKABLE const QObject *getObject() const
          {
              const QObject *object = nullptr;
              return object;
          }
      };
      #endif // MYTYPE_H
      

      I get the following warning at compile time:

      Warning: debug\MyApp\appMyAppqmltypes:16:71: Expected only name, type, revision, isPointer, isList, isCloned, isConstructor, and isJavaScriptFunction in script bindings.
       
      [import]

      Why isConstant cannot be used Method { } in .qmltypes? Am I missing something or it is a bug?

      Attachments

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

        Activity

          People

            ulherman Ulf Hermann
            pijaouen Pierre Jaouen
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews