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. QMetaMethod::tag() problem
QtWS25 Last Chance

QMetaMethod::tag() problem

Scheduled Pinned Locked Moved Solved General and Desktop
qmetaobjectqmetamethodtags
4 Posts 2 Posters 516 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 last edited by
    #1

    Hi All,

    I've got an odd problem related to QMetaMethod and the tag system.
    I've got a function:

        MY_CUSTOM_TAG double playheadPosition() const;
    

    And elsewhere in my code I do the usual,

    QMetaMethod mm = win.metaObject()->method(functionIndex);
        qDebug() << mm.tag(); // prints MY_CUSTOM_TAG
    

    As described at: QMetaMethod tag Howto

    Most of the time this pattern works, However I have found a few instances where the tag is not being returned correctly from the tag() call?
    ie. the tag(), returns nothing for the function with the MY_CUSTOM_TAG prepended to the function declaration.
    One instance of this is the above example, however the really funky thing is that if I change the return type to be float instead of double it works!

    So, I would really appreciate it if anyone could provide some insight into a solution, and why the tag system might be working correctly with a float return type, but not a double?

    I've looked at the moc file generated and it does appear to have some strangeness inside compared to the files that have functions that work with the tag stuff properly.
    Namely there are functions inside the qt_static_metacall function in the moc file that mention the MY_CUSTOM_TAG , and I suspect that these functions are also not generating the correct tag either.

    I do have a lot of functions marked with my tag, ( in the 100's )
    Is there any chance I could run into some limit here?
    Is there something special about the double type?
    Why would changing it to float solve the issue?
    FWIW I think I also have instances of it happening with functions that return an int.
    I need the precision of double so just changing to float is not really an option.

    Qt. 5.15.2, targeting x86_64, on windows building with VisualStudio

    Thanks,
    James

    Christian EhrlicherC 1 Reply Last reply
    0
    • J Jammin44fm

      Hi All,

      I've got an odd problem related to QMetaMethod and the tag system.
      I've got a function:

          MY_CUSTOM_TAG double playheadPosition() const;
      

      And elsewhere in my code I do the usual,

      QMetaMethod mm = win.metaObject()->method(functionIndex);
          qDebug() << mm.tag(); // prints MY_CUSTOM_TAG
      

      As described at: QMetaMethod tag Howto

      Most of the time this pattern works, However I have found a few instances where the tag is not being returned correctly from the tag() call?
      ie. the tag(), returns nothing for the function with the MY_CUSTOM_TAG prepended to the function declaration.
      One instance of this is the above example, however the really funky thing is that if I change the return type to be float instead of double it works!

      So, I would really appreciate it if anyone could provide some insight into a solution, and why the tag system might be working correctly with a float return type, but not a double?

      I've looked at the moc file generated and it does appear to have some strangeness inside compared to the files that have functions that work with the tag stuff properly.
      Namely there are functions inside the qt_static_metacall function in the moc file that mention the MY_CUSTOM_TAG , and I suspect that these functions are also not generating the correct tag either.

      I do have a lot of functions marked with my tag, ( in the 100's )
      Is there any chance I could run into some limit here?
      Is there something special about the double type?
      Why would changing it to float solve the issue?
      FWIW I think I also have instances of it happening with functions that return an int.
      I need the precision of double so just changing to float is not really an option.

      Qt. 5.15.2, targeting x86_64, on windows building with VisualStudio

      Thanks,
      James

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      I doubt there is a limit. Reduce your code until you only have one working and one non-working function and post it here then.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      J 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        I doubt there is a limit. Reduce your code until you only have one working and one non-working function and post it here then.

        J Offline
        J Offline
        Jammin44fm
        wrote on last edited by
        #3

        @Christian-Ehrlicher

        After a bit more research I'm pretty sure it's a Qt Bug.
        MOC compiler get wrong metamethod tag in some cases

        No information if the issue is fixed in newer version of Qt?
        It lists 6.0.0 as an affected version, but nothing more recent.
        but the resolution is still labeled unresolved?

        Looks like it will be possible to swap qreal for double, and qint32 for int though,
        and things might work then.

        Cheers,
        James

        Christian EhrlicherC 1 Reply Last reply
        0
        • J Jammin44fm

          @Christian-Ehrlicher

          After a bit more research I'm pretty sure it's a Qt Bug.
          MOC compiler get wrong metamethod tag in some cases

          No information if the issue is fixed in newer version of Qt?
          It lists 6.0.0 as an affected version, but nothing more recent.
          but the resolution is still labeled unresolved?

          Looks like it will be possible to swap qreal for double, and qint32 for int though,
          and things might work then.

          Cheers,
          James

          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Jammin44fm said in QMetaMethod::tag() problem:

          It lists 6.0.0 as an affected version, but nothing more recent

          Then its not yet fixed. If there is no minimal reproducer you can add one.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          0
          • J Jammin44fm has marked this topic as solved on

          • Login

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