Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. Can I create QApplication in DLL with Qt6.4.2?
QtWS25 Last Chance

Can I create QApplication in DLL with Qt6.4.2?

Scheduled Pinned Locked Moved Solved Qt 6
4 Posts 2 Posters 451 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Cata123C Offline
    Cata123C Offline
    Cata123
    wrote on last edited by Cata123
    #1

    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

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Did you follow the same deployment procedure as you would with an application ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      Cata123C 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        Did you follow the same deployment procedure as you would with an application ?

        Cata123C Offline
        Cata123C Offline
        Cata123
        wrote on last edited by Cata123
        #3

        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.

        SGaistS 1 Reply Last reply
        0
        • Cata123C Cata123

          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.

          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @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.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • Cata123C Cata123 has marked this topic as solved on

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved