Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to get QMetaMethod from Object::method?
Forum Updated to NodeBB v4.3 + New Features

How to get QMetaMethod from Object::method?

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 412 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kitfox
    wrote on last edited by
    #1

    Given I have a QObject inheriting object called Foo with a method on it called bar, what's the easiest way to get a QMetaMethod object that represents Foo::bar? I'm doing this to create a property-like object that need to encapsulate a getter, setter and notify signal present on Foo.

    kshegunovK 1 Reply Last reply
    0
    • K kitfox

      Given I have a QObject inheriting object called Foo with a method on it called bar, what's the easiest way to get a QMetaMethod object that represents Foo::bar? I'm doing this to create a property-like object that need to encapsulate a getter, setter and notify signal present on Foo.

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by kshegunov
      #2

      @kitfox said in How to get QMetaMethod from Object::method?:

      Given I have a QObject inheriting object called Foo with a method on it called bar, what's the easiest way to get a QMetaMethod object that represents Foo::bar?

      From the docs:

      int functionIndex = qobj.metaObject()->indexOfMethod("testFunc()");
      QMetaMethod mm = qobj.metaObject()->method(functionIndex);
      

      https://doc.qt.io/qt-5/qmetamethod.html
      https://doc.qt.io/qt-5/qmetaobject.html#indexOfMethod
      https://doc.qt.io/qt-5/qmetaobject.html#normalizedSignature

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      3

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved