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. Problem with QMetaMethod::returnType with typedef type

Problem with QMetaMethod::returnType with typedef type

Scheduled Pinned Locked Moved Solved General and Desktop
qmetaobjectinvokemethodqmetatype
2 Posts 1 Posters 309 Views
  • 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.
  • J Offline
    J Offline
    Jammin44fm
    wrote on 12 Jul 2023, 00:46 last edited by Jammin44fm 7 Dec 2023, 01:28
    #1

    Hey All,

    I'm running into a problem with QMetaMethod::returnType, which is in turn causing my invoke of said function to fail.

    The function in Question is declared as:
    JSValue require(const QString& fileName);

    where JSValue is:
    typedef uint64_t JSValue;

    After creating the QObject based class that contains the require function,
    I iterate through all the methods using metaObject() to access each individual QMetaMethod info for each function.

    The problem is that when I get the return type for the require function, it returns 0,
    ie. QMetaType::UnknownType, which in turn makes it impossible to use the function via an invoke call, as it does not return the correct return value properly.

    I'm pretty sure everything else is working correctly, as a different function in the same class with the declaration:
    bool verbose(const QString&);
    works fine, and return 1 from the returnType() function.

    Even changing the return type to be an explicit uint64_t still gives the same, problematic, result?

    EDIT.
    So after some more testing it appears that changing the return type to be qulonglong, results in the function working and it gives the correct return type value, '5' when I the returnType() function. However changing every instance of JSValue to qulonglong is a not a reasonable solution.

    In the Qt code this is defined as:
    typedef quint64 qulonglong;
    typedef unsigned __int64 quint64; /* 64 bit unsigned */

    But changing the original JSValue typedef to be:
    typedef unsigned __int64 JSValue;

    Doesn't work???
    Are there some special rules around what types can be used as return types for functions with QMetaMethod?

    This is really causing me some issues, so any help feedback would be most appreciated.

    • James

    PS. FYI. on Qt5.15

    J 1 Reply Last reply 12 Jul 2023, 05:02
    0
    • J Jammin44fm
      12 Jul 2023, 00:46

      Hey All,

      I'm running into a problem with QMetaMethod::returnType, which is in turn causing my invoke of said function to fail.

      The function in Question is declared as:
      JSValue require(const QString& fileName);

      where JSValue is:
      typedef uint64_t JSValue;

      After creating the QObject based class that contains the require function,
      I iterate through all the methods using metaObject() to access each individual QMetaMethod info for each function.

      The problem is that when I get the return type for the require function, it returns 0,
      ie. QMetaType::UnknownType, which in turn makes it impossible to use the function via an invoke call, as it does not return the correct return value properly.

      I'm pretty sure everything else is working correctly, as a different function in the same class with the declaration:
      bool verbose(const QString&);
      works fine, and return 1 from the returnType() function.

      Even changing the return type to be an explicit uint64_t still gives the same, problematic, result?

      EDIT.
      So after some more testing it appears that changing the return type to be qulonglong, results in the function working and it gives the correct return type value, '5' when I the returnType() function. However changing every instance of JSValue to qulonglong is a not a reasonable solution.

      In the Qt code this is defined as:
      typedef quint64 qulonglong;
      typedef unsigned __int64 quint64; /* 64 bit unsigned */

      But changing the original JSValue typedef to be:
      typedef unsigned __int64 JSValue;

      Doesn't work???
      Are there some special rules around what types can be used as return types for functions with QMetaMethod?

      This is really causing me some issues, so any help feedback would be most appreciated.

      • James

      PS. FYI. on Qt5.15

      J Offline
      J Offline
      Jammin44fm
      wrote on 12 Jul 2023, 05:02 last edited by
      #2

      @Jammin44fm

      It seems the solution was to use;
      qRegisterMetaType<JSValue>("JSValue");

      Earlier in the code to register JSValue as a meta Type.
      I had already tried this, but was missing the string "JSValue" from the call.
      So it seems that both the type and the string are required.

      All good working now,
      Hopefully it will all work in 6.5 too, as it seems Qt has removed the string variant from the SDK.

      1 Reply Last reply
      0
      • J Jammin44fm has marked this topic as solved on 12 Jul 2023, 05:02

      1/2

      12 Jul 2023, 00:46

      • Login

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