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



  • 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?


  • Moderators

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


  • Lifetime Qt Champion

    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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.