简体   繁体   中英

Full type names in QMetaMethod

Is it possible to receive full type names in QMetaMethod of return type and or argument types?

Example,

namespace N1 {
namespace N2 {
    class C1: public QObject {
      Q_OBJECT
    };
}
}


class C2: public QObject {
  Q_OBJECT
  public:
  typedef N1::N2::C1 C1T;

  Q_INVOKABLE void foo(C1T c1); 
};

QMetaMethod method;

// some logic to find method void foo(C1T) of C2

auto name  = method.parameterNames(); // return "C1T"

auto name2 = C1T::staticMetaObjec.className()  // return "N1::N2::C1"

Is it possilbe to find out the full name of method's parameter name, not "C1T", but "N1::N2::C1", or at least "C1"? The same problem with namespaces, that if C2 is in N1 namespace and I use N2::C1 as an argument type, it returns "N2::C1", can I have "N1::N2::C2" ?

moc does not understand C++ type system. To moc, a type is a string, and is only equivalent to another type if the strings match. You have to stick to one way of representing the parameter type, and use that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM