@Pl45m4 Thank you for your reply. I tried. here is my example code:
Version A
void start_app(void)
{
int argc = 0;
char*argv[] = {nullptr};
QCoreApplication a(argc, argv);
a.exec();
}
void init_dll()
{
std::thread th(start_app);
h.detach();
}
I use QLibrary to resolve "init_dll" function and run it.This time the main program is not blocked, no crash down occured .But the signal slot did not work, and QTCPSocket cannot be used.
Version B
void start_app(void)
{
int argc = 0;
char*argv[] = {nullptr};
QCoreApplication a(argc, argv);
a.exec();
}
void init_dll()
{
start_app();
}
when I call "init_dll" function in DLLs,the main program will be blocked from running, but the QTCPSocket and signal slots function is workable.
How can I modify the DLL code so it doesn't block the main program's execution and still allows using QTcpSocket and other Qt components that depend on the event loop(QCoreApplication)?