I have such class:
#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();
}
I have a signal:
void progress(const ProcessHandle* const self, const int value);
I want to connect it through QueuedConnedtion. I keep getting this message:
QObject::connect: Cannot queue arguments of type 'ProcessHandle*const'
(Make sure 'ProcessHandle*const' is registered using qRegisterMetaType().)
I register my class like this after it's declaration:
Q_DECLARE_METATYPE(taservices::ProcessHandle*);
I also added this static method which I call from constructor:
void ProcessHandle::registerAsMetaType()
{
static bool called = false;
if(!called) {
called = true;
qRegisterMetaType<ProcessHandle*>("taservices::ProcessHandle*");
}
}
I tried to register const
pointer as well:
qRegisterMetaType<ProcessHandle*const>("taservices::ProcessHandle*const");
It causes following error:
error C2440: 'return' : cannot convert from 'taservices::ProcessHandle *const *' to 'void *'
So how do I make my class work with Queued connections?
const
, since you should not change it to different address. – Ondrea