关于在Qt中信号槽传递QObject类型的参数的方法:
1.第一种注册法:qRegisterMetatType<MoSystemLog>("MoSystemLog")
2. 第二种修改Connect,加一个属性Qt::directConnection.
connect(cm, SIGNAL(sendLog(QUuid, QByteArray, bool)),this,SLOT(sendRes(QUuid,QByteArray,bool)), Qt::DirectConnection);
第二种方法有风险
1、第一种解决方法,即使用排队方式的信号-槽机制,Qt的元对象系统(meta-object system)必须知道信号传递的参数类型。这样元系统可以将信号参数COPY下来,放在队列中等待事件唤醒,供槽函数调用。Just a note here, if you would have to pass custom data types between threads in Qt. As we know, a signal-slot connection is then (by default) of type Qt::QueuedConnection. Because in such a situation Qt needs to store passed parameters for a while, it creates their temporary copies. If it doesn’t recognize the passed data type, throws out an error:
2、第二种方法,直接调用对方槽函数,不需要保存参数。但是官方认为这样做有风险。