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

modernize QMetaObject::invokeMethod using std::invoke C++17

    XMLWordPrintable

Details

    Description

      Hi,

      QMetaObject::invokeMethod currently depends on Q_INVOKABLE to be present to allow a function to be called. That doesn't have to be the case anymore in terms of it's functionality and C++17.

      The method already gets the object where it has to invoke a function. Next it only needs a function pointer address to work where that now is a method name as string. Basically the same like the modern connect syntax but only of the slot part.

      std::invoke can (should?) be used internally, that function is available since C+17: https://en.cppreference.com/w/cpp/utility/functional/invoke but it looks like a library side implementation detail only so i wouldn't be surprised if you could make it work with C14 or even C+11.

      This will make QMetaObject::invokeMethod more broadly usable as it would (probably?) have the same rules as the new signal/slot connection syntax making it possible to call any public function that way as opposed to only those specified by Q_INVOKABLE.

      Cheers,
      Mark

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            markg85 Mark
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes