CPPProger
15th June 2020, 16:00
Friends, I'm yellow beginner in Qt. Tell me, please, is it possible to use QCoreApplication inside a non-GUI thread. I need to make the difficult asynchronous computing part of the application in C ++ (i use from Qt signals and slots, and sockets) and build a dynamic library. Then connect it to the JavaFX GUI application.
Can i to run Qt-code with QCoreApplication in non-main C ++ stream (std :: thread) or not? I see warning
QApplication was not created in main() thread
and it's alarming me.
Maybe there is an example of this kind of use of Qt: calculation in C ++ Qt and use it as a dynamic library in Java GUI?
Added after 4 minutes:
Friends, I'm yellow beginner in Qt. Tell me, please, is it possible to use QCoreApplication inside a non-GUI thread. I need to make the difficult asynchronous computing part of the application in C ++ (i use from Qt signals and slots, and sockets) and build a dynamic library. Then connect it to the JavaFX GUI application.
Can i to run Qt-code with QCoreApplication in non-main C ++ stream (std :: thread) or not? I see warning
QApplication was not created in main() thread
and it's alarming me.
Maybe there is an example of this kind of use of Qt: calculation in C ++ Qt and use it as a dynamic library in Java GUI?
Added after 45 minutes:
I try
Client * client = nullptr;
std::thread th
(
[&]
{
QCoreApplication app(argc, argv);
client = new Client;
return app.exec();
}
);
th.detach();
while(!client)
{
qDebug() << "nulptr";
QThread::usleep(1000);
}
client->setHostName("localhost");
and see
WARNING: QApplication was not created in the main() thread.
nulptr
nulptr
nulptr
QObject: Cannot create children for a parent that is in a different thread.
(Parent is QSslSocket(0x7f4da80080c0), parent's thread is QThread(0x7f4da8000c60), current thread is QThread(0x56367f1e3ab0)
Can i to run Qt-code with QCoreApplication in non-main C ++ stream (std :: thread) or not? I see warning
QApplication was not created in main() thread
and it's alarming me.
Maybe there is an example of this kind of use of Qt: calculation in C ++ Qt and use it as a dynamic library in Java GUI?
Added after 4 minutes:
Friends, I'm yellow beginner in Qt. Tell me, please, is it possible to use QCoreApplication inside a non-GUI thread. I need to make the difficult asynchronous computing part of the application in C ++ (i use from Qt signals and slots, and sockets) and build a dynamic library. Then connect it to the JavaFX GUI application.
Can i to run Qt-code with QCoreApplication in non-main C ++ stream (std :: thread) or not? I see warning
QApplication was not created in main() thread
and it's alarming me.
Maybe there is an example of this kind of use of Qt: calculation in C ++ Qt and use it as a dynamic library in Java GUI?
Added after 45 minutes:
I try
Client * client = nullptr;
std::thread th
(
[&]
{
QCoreApplication app(argc, argv);
client = new Client;
return app.exec();
}
);
th.detach();
while(!client)
{
qDebug() << "nulptr";
QThread::usleep(1000);
}
client->setHostName("localhost");
and see
WARNING: QApplication was not created in the main() thread.
nulptr
nulptr
nulptr
QObject: Cannot create children for a parent that is in a different thread.
(Parent is QSslSocket(0x7f4da80080c0), parent's thread is QThread(0x7f4da8000c60), current thread is QThread(0x56367f1e3ab0)