I have tried a couple of times to make a library of mine in C++ accessible from QML.

I can instantiate the classes, call their methods but i am having problems when it comes to receive a signal with custom typed arguments. When the signals are emitted, in the debugger console i get the following error:

from Qt Creator debugger:
(5cc.135c): Unknown exception - code 8001010e (first chance)
Exception at 0x75c1b9bc, code: 0x8001010e: , flags=0x1 (execution cannot be continued) in KERNELBASE!RaiseException
from Visual Studio 2008 debugger:
First-chance exception at 0x75c1b9bc in FromCPPtoQML.exe: 0x8001010E: The application called an interface that was marshalled for a different thread.
It seems it has something to do with the fact that the signals are emitted in a different thread?

  • All the classes that i want to be visible inherit from QObject
  • Any custom class whose instances are sent through signals are registered using the function: qRegisterMetaType
  • All classes are registered to be visible to QML through qmlRegisterType
  • I use Qt 4.7.4 on Windows. Unfortunately i don't have any device compatible with Qt Quick to test it to other platforms. Qt Simulator can use the library (bluetooth functions).

Any ideas are welcomed.