Whether we can use COM or ActiveX only in main thread(GUI thread)?
This is an interesting question. I used to created a topic about how to create a QModbusClient Class correctly.And finally get rid of those fault error information when I didn't create a intialized QModbusClient Object in my subclass(which I move it to an sub-thread).
These two days I use a COM to read back a powermeter value,the similar happened again.When I created a QAxObject Object in a user-defined class,it shows some mistakes("Make sure 'QVariant&' is registered using qRegisterMetaType",I searched it and some people said it is related to multi-threads),however,when I created it in mainwindow or any qt designer classs,the error code disappears.
So here is the question:whether we can only use COM or activex in a GUI thread??If not,what should I pay attention to?
When you say
user defined class
is that a QObject subclass?
@mrjj Yes...Is that having some conflicts with the COM?
nope, it its just the note in the docs
"Warning: You can subclass QAxObject, but you cannot use the Q_OBJECT macro in the subclass (the generated moc-file will not compile), so you cannot add further signals, slots or properties. This limitation is due to the metaobject information generated in runtime. To work around this problem, aggregate the QAxObject as a member of the QObject subclass."
so I wondered if the errors u get was moc errors.
Was just a thought.
if you subclass is indeed QObject based and you aggregate the QAxObject,
i dont think its the reason for your errors.
@mrjj thx,I am astonished and I will try it soon...:(