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

Code snippet in QMetaMethod documentation missing variable definition

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 5.2.0
    • Fix Version/s: 5.3.0
    • Component/s: Documentation
    • Labels:
      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

        For Gerrit Dashboard: QTBUG-38871
        # Subject Branch Project Status CR V

          Activity

            People

            Assignee:
            treinio Topi Reiniƶ
            Reporter:
            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