Can I create QApplication in DLL with Qt6.4.2?
-
I created a DLL using Qt 6.4.2 and created a QApplication instance in a function of that DLL in the hope of opening the event loop and displaying a QWidget window.
But when instantiating QAplication, the entire program crashes because "Qt This application failed to start because no Qt platform plugin could be initialized...."
This is an unsolvable issue I've had since upgrading to Qt6, has anyone had it before me and found a solution? Can you help me solve the problem? Thanks.Qt Version: 6.4.2
OS: Windows 11 -
Hi and welcome to devnet,
Did you follow the same deployment procedure as you would with an application ?
-
Hi and welcome to devnet,
Did you follow the same deployment procedure as you would with an application ?
Hi @SGaist
My main program is lua script. Use luajit ffi to call the dll compiled by Qt. I believe that the problem is not the deployment environment, because I set the QT before creating the QApplication instance_ QPA_ PLATFORM_ PLUGIN_ After the PATH environment variable, the problem is solved. like this:qputenv("QT_QPA_PLATFORM_PLUGIN_PATH", ".../platforms"); QApplication app(argc, argv);
The platforms folder is next to the dll file.
I want to know if there is a better solution than this, or if this is a bug in Qt6, because I haven't encountered this problem before when using Qt4. -
Hi @SGaist
My main program is lua script. Use luajit ffi to call the dll compiled by Qt. I believe that the problem is not the deployment environment, because I set the QT before creating the QApplication instance_ QPA_ PLATFORM_ PLUGIN_ After the PATH environment variable, the problem is solved. like this:qputenv("QT_QPA_PLATFORM_PLUGIN_PATH", ".../platforms"); QApplication app(argc, argv);
The platforms folder is next to the dll file.
I want to know if there is a better solution than this, or if this is a bug in Qt6, because I haven't encountered this problem before when using Qt4.@Cata123 if you need to set that variable, it means that the folder containing the plugins is not at the expected place.
The solution itself is not bad per se though.Qt 4 has a different architecture for the platform backend part hence the "new" behaviour.
-
C Cata123 has marked this topic as solved on