Hi,
I have a non-Qt type that I am trying to use in a signal/slot connection. I would like to do the following:
In Header
class MyClass
{
...
signals:
void negotiate( const unsigned int& timeout, const eos::ResourceSetRequest& request );
...
}
class MyClass
{
...
signals:
void negotiate( const unsigned int& timeout, const eos::ResourceSetRequest& request );
...
}
To copy to clipboard, switch view to plain text mode
In CPP
void MyClass::someFunction()
{
emit negotiate( timeout, request );
}
void MyClass::someFunction()
{
emit negotiate( timeout, request );
}
To copy to clipboard, switch view to plain text mode
However, when I try this the connection isn't being made. From the documentation it looks like I need to register the type eos::ResourceSetRequest as a QMetaType before it can be sent as a signal argument.
Is this correct?
If so, then how do I register the non-Qt type as a new QMetaType?
It looks like I need to place the following in the CPP file:
Q_DECLARE_METATYPE(eos::ResourceSetRequest);
int reqID = qRegisterMetaType<eos::ResourceSetRequest>("eos::ResourceSetRequest");
Q_DECLARE_METATYPE(eos::ResourceSetRequest);
int reqID = qRegisterMetaType<eos::ResourceSetRequest>("eos::ResourceSetRequest");
To copy to clipboard, switch view to plain text mode
However, when I do this I get the following compile error:
c:\Qt\4.1.4\include\QtCore\../../src\corelib\kernel\qmetatype.h(85) : error C2512: 'eos::ResourceSetRequest' : no appropriate default constructor available
c:\Qt\4.1.4\include\QtCore\../../src\corelib\kernel\qmetatype.h(97) : see reference to function template instantiation 'void *qMetaTypeConstructHelper<T>(const T *)' being compiled
with
[
T=eos::ResourceSetRequest
]
DeviceQResourceFrame.cpp(22) : see reference to function template instantiation 'int qRegisterMetaType<eos::ResourceSetRequest>(const char *,T *)' being compiled
with
[
T=eos::ResourceSetRequest
]
Is this a Qt problem or a problem with constructing the non-Qt class?
Any advice on this would be greatly appreciated.
Bookmarks