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. [resolved]Error with Q_ARG macro
Forum Update on Monday, May 27th 2025

[resolved]Error with Q_ARG macro

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.0k 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.
  • T Offline
    T Offline
    treaves
    wrote on 13 Dec 2013, 16:59 last edited by
    #1

    I have code that is using QMetaObject::invoke to invoke a method. As at compile time I do not know how many arguments (or which method) will be invoked, I use a QGenericArgument array, and then call invoke with the populated array like so:
    @invoke(instance Qt::DirectConnection, argumentTable[0], argumentTable[1], ...@

    This works if two consecutive arguments are not of the same type. If two consecutive arguments are of the same type, the previous is replaced with the last. So if 0 & 1 are of type QString and int, the call works. However, if 0 & 1 are both of QString (yes, these would be two different methods), and 0 =="A" & 1=="B", then both values end up "B".

    I understand my explanation is confusing. Please see code at:
    https://github.com/treaves/tufao/blob/master/src/classhandlermanager.cpp#L259

    You can see in the code about that how the variables are set. You can also see my qDebug statements. Here is some output:

    When the two adjacent arguments are of different type:
    @Processing "chapter"
    Processed QString "qaz" at index 2
    Processing "pageNumber"
    Processed int 3 at index 3
    "0x7fef48410790"
    "0x7fef49800310"
    "0x7fff59ae8ee0"
    "0x7fff59ae8fb4" @

    And when they are of the same type:
    @Processing "chapter"
    Processed QString "2" at index 2
    Processing "pageNumber"
    Processed QString "3" at index 3
    "0x7fef48410790"
    "0x7fef499000b0"
    "0x7fff59ae8ee0"
    "0x7fff59ae8ee0" @

    So you can see that when the argument is set, the index are correct, and the values are indeed different. But the pointers end up being the same in the second case.

    Am I doing something incorrectly, or is this a defect in Qt?

    For this output, the test code is at:
    https://github.com/treaves/tufao/tree/master/examples/sample_plugin

    I'd appreciate any input.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      treaves
      wrote on 13 Dec 2013, 19:17 last edited by
      #2

      This was a variable scope issue.

      1 Reply Last reply
      0

      1/2

      13 Dec 2013, 16:59

      • 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