我有这样的课:
#include <QObject>
namespace taservices
{
class ProcessHandle : public QObject
{
Q_OBJECT
public:
ProcessHandle(const void* const processContextPointer, const QString& process_id = "", QObject *parent = 0);
ProcessHandle();
signals:
void progress(const ProcessHandle* const self, const int value);
private:
static void registerAsMetaType();
}
Run Code Online (Sandbox Code Playgroud)
我有一个信号:
void progress(const ProcessHandle* const self, const int value);
Run Code Online (Sandbox Code Playgroud)
我想通过QueuedConnedtion连接它。我不断收到此消息:
QObject::connect: Cannot queue arguments of type 'ProcessHandle*const'
(Make sure 'ProcessHandle*const' is registered using qRegisterMetaType().)
Run Code Online (Sandbox Code Playgroud)
声明后,我像这样注册我的课程:
Q_DECLARE_METATYPE(taservices::ProcessHandle*);
Run Code Online (Sandbox Code Playgroud)
我还添加了从构造函数调用的此静态方法:
void ProcessHandle::registerAsMetaType()
{
static bool called = false;
if(!called) {
called …Run Code Online (Sandbox Code Playgroud)