DllImport (c#) and Qt
Hi. I have a dll written in Qt with a QThread object in it. The Qthread sends an event every each second to an callback in the C# program.
If the Qthread invokes the callback directly the program works. I have in the C# layer on event every second.
But If I use "connect" instead of the callback directly I never have the event.
Sounds an the event queue in the Qt dll does not starts correctly.
How can I start it?
You should show your code.
pCallback= NULL; Timer= new QTimer(); connect(Timer, SIGNAL(timeout()), this, SLOT(OnTimer())); Timer->start(1000); ThTest= new QThTest(this); ThTest->start(); qDebug() << "DllTest::DllTest()";
If I use this dll with a program written in Qt che row below works perfectly.
connect(Timer, SIGNAL(timeout()), this, SLOT(OnTimer()));
But if I use this dll with a program written in C# I never have the event. I think the problem is that a program written in Qt has got an compatible internal event queue but the C# program not.
You might have a look at the Dot Net Example
It explains the use of managed code with Qt.
Also, there is a similar topic
Hope it helps you in the right direction.
@mrdebug I guess you do not have event loop in your dll and since there is no Qt event loop in a pure C# program it does not work.