Question

I have a thread from which I need to send a signal with a parameter to a pointer like the following:

connect(insThread, SIGNAL(sgGetCurrentElement(QWebElement&)), this, SIGNAL(sgGetCurrentElement(QWebElement&)));

where insThread is the thred. However I got error:

QObject::connect: Cannot queue arguments of type ‘QWebElement&’ (Make sure ‘QWebElement&’ is registered using qRegisterMetaType().)

I already know that I need to use qRegisterMetaType but I couldn't figure out how I can construct it. I tried

qRegisterMetaType<QWebElement&>("myElement");

but failed. How can I solve this?

Thanks.

Was it helpful?

Solution

I assume you are trying to register the QWebElement with a reference (&) because have prototyped the slot to take QWebElement as a reference, but this is not a very good idea if you're posting the signal from one thread to another, see here. Anyway, as Laszlo pointed out, you have to register the base type, it is meaningless to register the type with the reference tag (&).

OTHER TIPS

I am not sure why you are trying to register it with &, but do it without that as follows:

qRegisterMetaType<QWebElement>("myElement");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top