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

Code snippet in QMetaMethod documentation missing variable definition

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.3.0
    • 5.2.0
    • Documentation
    • None

    Description

      Code snippet location:
      http://qt-project.org/doc/qt-5/qmetamethod.html#invoke

      Current code snippet:

      QString retVal;
      QByteArray normalizedSignature = QMetaObject::normalizedSignature("compute(QString, int, double)");
      int methodIndex = obj->metaObject()->indexOfMethod(normalizedSignature);
      QMetaMethod method = metaObject->method(methodIndex);
      method.invoke(obj,
                    Qt::DirectConnection,
                    Q_RETURN_ARG(QString, retVal),
                    Q_ARG(QString, "sqrt"),
                    Q_ARG(int, 42),
                    Q_ARG(double, 9.7));
      

      Should either be:

      QString retVal;
      QMetaObject metaObject = obj->metaObject();
      QByteArray normalizedSignature = QMetaObject::normalizedSignature("compute(QString, int, double)");
      int methodIndex    = metaObject->indexOfMethod(normalizedSignature);
      QMetaMethod method = metaObject->method(methodIndex);
      method.invoke(obj,
                    Qt::DirectConnection,
                    Q_RETURN_ARG(QString, retVal),
                    Q_ARG(QString, "sqrt"),
                    Q_ARG(int, 42),
                    Q_ARG(double, 9.7));
      

      or:

      QString retVal;
      QByteArray normalizedSignature = QMetaObject::normalizedSignature("compute(QString, int, double)");
      int methodIndex    = obj->metaObject()->indexOfMethod(normalizedSignature);
      QMetaMethod method = obj->metaObject()->method(methodIndex);
      method.invoke(obj,
                    Qt::DirectConnection,
                    Q_RETURN_ARG(QString, retVal),
                    Q_ARG(QString, "sqrt"),
                    Q_ARG(int, 42),
                    Q_ARG(double, 9.7));
      

      Attachments

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

        Activity

          People

            treinio Topi Reiniƶ
            nweyand NWeyand
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes