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?
Forum Updated to NodeBB v4.3 + New Features

Can I create QApplication in DLL with Qt6.4.2?

Scheduled Pinned Locked Moved Solved Qt 6
4 Posts 2 Posters 464 Views 1 Watching
  • 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.
  • C Offline
    C Offline
    Cata123
    wrote on 12 Mar 2023, 02:15 last edited by Cata123 3 Dec 2023, 02:22
    #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
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 12 Mar 2023, 20:02 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

      C 1 Reply Last reply 13 Mar 2023, 07:21
      0
      • S SGaist
        12 Mar 2023, 20:02

        Hi and welcome to devnet,

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

        C Offline
        C Offline
        Cata123
        wrote on 13 Mar 2023, 07:21 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.

        S 1 Reply Last reply 14 Mar 2023, 20:42
        0
        • C Cata123
          13 Mar 2023, 07:21

          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.

          S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 14 Mar 2023, 20:42 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
          • C Cata123 has marked this topic as solved on 15 Mar 2023, 01:52

          1/4

          12 Mar 2023, 02:15

          • Login

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