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. Type argument of Q_DECLARE_METATYPE(T*) must be fully defined
Forum Updated to NodeBB v4.3 + New Features

Type argument of Q_DECLARE_METATYPE(T*) must be fully defined

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 3.3k 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.
  • A Offline
    A Offline
    Ania
    wrote on last edited by
    #1

    In main thread, I created another subthread, and the struct must be transfered to the subthread. Here is my Connect in the main thread:

    HeartThreadMsg::HeartThreadRequest threadReqMsg;
    threadReqMsg.set_ack_identity(1);
    qRegisterMetaType<HeartThreadMsg::HeartThreadRequest>("HeartThreadMsg::HeartThreadRequest");
    qRegisterMetaType<struct CDK::RRFramework>("struct CDK::RRFramework");
    emit operSig(m_RRFW, threadReqMsg);
    

    m_RRFW is a struct, but it is not fully defined, it defined like this:

    namespace CDK
    {
          struct RRFramework;
    }
    

    when I compile the application, it shows that Type argument of Q_DECLARE_METATYPE(T*) must be fully defined, if I do want to declare the struct, and the struct can not be fully defined, does anyone know how to solve this, or does there has other method?

    jsulmJ 1 Reply Last reply
    0
    • A Ania

      In main thread, I created another subthread, and the struct must be transfered to the subthread. Here is my Connect in the main thread:

      HeartThreadMsg::HeartThreadRequest threadReqMsg;
      threadReqMsg.set_ack_identity(1);
      qRegisterMetaType<HeartThreadMsg::HeartThreadRequest>("HeartThreadMsg::HeartThreadRequest");
      qRegisterMetaType<struct CDK::RRFramework>("struct CDK::RRFramework");
      emit operSig(m_RRFW, threadReqMsg);
      

      m_RRFW is a struct, but it is not fully defined, it defined like this:

      namespace CDK
      {
            struct RRFramework;
      }
      

      when I compile the application, it shows that Type argument of Q_DECLARE_METATYPE(T*) must be fully defined, if I do want to declare the struct, and the struct can not be fully defined, does anyone know how to solve this, or does there has other method?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Ania You need to call qRegisterMetaType somewhere where the struct is fully defined.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      sanojsubranS 1 Reply Last reply
      2
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        To add to @jsulm, you should use the version of qRegisterMetaType without argument. The one you are using is useful only for registering alias types.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1
        • jsulmJ jsulm

          @Ania You need to call qRegisterMetaType somewhere where the struct is fully defined.

          sanojsubranS Offline
          sanojsubranS Offline
          sanojsubran
          wrote on last edited by
          #4

          @jsulm Do you mean in the header, where the struct is defined?

          I am also facing the same issue. Any help would be appreciated.

          jsulmJ 1 Reply Last reply
          0
          • sanojsubranS sanojsubran

            @jsulm Do you mean in the header, where the struct is defined?

            I am also facing the same issue. Any help would be appreciated.

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @sanojsubran said in Type argument of Q_DECLARE_METATYPE(T*) must be fully defined:

            Do you mean in the header, where the struct is defined?

            Somewhere in your code where the definition of the struct is known.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            1
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              To add to @jsulm, it's pretty usual to have that macro at the bottom of the header where the class/struct is defined.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

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