navid
28th March 2010, 14:53
hi,
I always after application running, receive debug text of:
QObject::connect: Cannot queue arguments of type 'MyStruct'
(Make sure 'MyStruct' is registered using qRegisterMetaType().)
I have defined MyStruct in an accessible header file:
myheader.h
////////////////////
#ifndef MYHEADER_H
#define MYHEADER_H
#include <QObject>
#include <QMetaType>
struct MyStruct
{
int ...
QString ...
double ...
MyStruct(...) :
...
{}
MyStruct operator=(const MyStruct& tother)
{
...
return *this;
}
bool operator!=(const MyStruct& tother)
{
...
}
};
Q_DECLARE_METATYPE(MyStruct)
class MyHeader: public QObject
{
Q_OBJECT
...
}
#endif // MYHEADER_H
///////////////////
and I have used it in a thread:
mythread.h
////////////
...
#include <QThread>
#include "myheader.h"
#include <QMetaType>
Q_DECLARE_METATYPE(QList<int>)
Q_DECLARE_METATYPE(QList<MyStruct>)
class MyThread: public QThread
{
Q_OBJECT
...
}
...
//////////
mythread.cpp
//////////////////
#include "mythread.h"
MyThread::MyThread(QObject *parent):
QThread(parent)
{
}
MyThread::~MyThread()
{
}
void MyThread::run()
{
qRegisterMetaType<QList<int> >();
qRegisterMetaType< QList<MyStruct> >();
ThreadReceiverObject * my_reciever = new ThreadReceiverObject();
QObject::connect(otherthread,SIGNAL(sigReqSchedule (QList<MyStruct>, QList<int>, int)),
my_reciever,SLOT(onReqSchedule(QList<MyStruct>, QList<int>, int)));
...
}
/////////////////
where is the problem?
I always after application running, receive debug text of:
QObject::connect: Cannot queue arguments of type 'MyStruct'
(Make sure 'MyStruct' is registered using qRegisterMetaType().)
I have defined MyStruct in an accessible header file:
myheader.h
////////////////////
#ifndef MYHEADER_H
#define MYHEADER_H
#include <QObject>
#include <QMetaType>
struct MyStruct
{
int ...
QString ...
double ...
MyStruct(...) :
...
{}
MyStruct operator=(const MyStruct& tother)
{
...
return *this;
}
bool operator!=(const MyStruct& tother)
{
...
}
};
Q_DECLARE_METATYPE(MyStruct)
class MyHeader: public QObject
{
Q_OBJECT
...
}
#endif // MYHEADER_H
///////////////////
and I have used it in a thread:
mythread.h
////////////
...
#include <QThread>
#include "myheader.h"
#include <QMetaType>
Q_DECLARE_METATYPE(QList<int>)
Q_DECLARE_METATYPE(QList<MyStruct>)
class MyThread: public QThread
{
Q_OBJECT
...
}
...
//////////
mythread.cpp
//////////////////
#include "mythread.h"
MyThread::MyThread(QObject *parent):
QThread(parent)
{
}
MyThread::~MyThread()
{
}
void MyThread::run()
{
qRegisterMetaType<QList<int> >();
qRegisterMetaType< QList<MyStruct> >();
ThreadReceiverObject * my_reciever = new ThreadReceiverObject();
QObject::connect(otherthread,SIGNAL(sigReqSchedule (QList<MyStruct>, QList<int>, int)),
my_reciever,SLOT(onReqSchedule(QList<MyStruct>, QList<int>, int)));
...
}
/////////////////
where is the problem?