PDA

View Full Version : QT DLL based on QWebSocketServer called from MFC application



oop
11th February 2016, 11:03
Hi all,
I written a QT DLL based on QWebSocketServer class and link it to a MFC application.
Initialization is ok and listen function too but it happens that websockets calls from web pages are locked.
It seems a that the connection are not managed, I think the QT DLL needs some messages processor or similar.

Have you some suggestion?


I tried with QApplication::processEvents() but nothing good happens.

Some suggestion ? :)

sorry for my English.

Added after 34 minutes:

I solved (temporary) calling QApplication::exec() within DLL but this solution is not good.

anda_skoa
11th February 2016, 12:51
You probably don't need a QApplication, you could try with a QCoreApplication.

You either need to run the application object's event loop or move your socket stuff into a QThread and run its event loop.

Cheers,
_

oop
11th February 2016, 14:50
Hi, thx for answer.
Yes I derived from the more light QCoreApplication and it works fine for me.
QCoreApplication have less dipendencies than QApplication.

There is a way to wait a signal on new event to dispatch rather than call processEvent ciclically?

Thx :)

anda_skoa
11th February 2016, 15:42
QCoreApplication::exec() runs the event loop in a loop, no need for processEvents().

That loop waits until it gets any event, e.g. socket, timer, and then dispatches it to the designated receiver/handler object.

If the receiver emit signals as a result of the event you can handle them with the usual signal/slot mechanism.

Cheers,
_

oop
15th February 2016, 17:40
Hi, I solved following your second suggestion (move instance of QCoreApplication into a QThread) and then
call QCoreApplication::exec(). It are working very fine for me.
It is simple also quit all, it is enought to call QCoreApplication::quit() from mainthread and wait QThread::wait() for, thus end main thread.

Regards,
Giorgio