Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-29550

Can't set path to a platform plugin in a portable way

    XMLWordPrintable

Details

    Description

      Currently in Qt5 there is no way how to set a path to a platform plugin in a
      portable way for a deployment environment - due to restriction that platform plugin needs to be found already during creation of QApplication object.

      Proposed solution is:

      static void init()
      {
      QString plugindir;
      #ifdef Q_OS_MAC
      plugindir=QCoreApplication::applicationDirPath()+"/../../Plug-Ins"; // MyApp.app/Contents/MacOS/../../Plug-Ins
      #elif defined Q_OS_WIN
      plugindir=QCoreApplication::applicationDirPath()+"\\plugins"; // MyApp\bin\plugins
      #elif defined Q_OS_LINUX
      plugindir=QCoreApplicaton::applicationDirPath()+"/../plugins"; // MyApp/plugins
      #endif
      putenv( "QT_PLUGIN_PATH", plugindir );
      }
      
      int main(int argc, char *argv[] )
      {
      init();
      QApplication a(argc, argv);
      ….
      }
      

      If someone moves the whole application structure (Mac OS bundle for example), then plugin path still would be resolved correctly.

      This would require QCoreApplication::applicationDirPath() to be truly static. Currently it depends on QCoreApplication instance. Its easy to remove that requirement in applicationDirPath() and applicationFilePath() [which is called by applicationDirPath() ].

      The issue is that we can't remove dependency to "self" in QCoreApplication::arguments(), which is called from applicationFilePath() (for blackberry and Q_OS_UNIX). It would be possible to make it truly static
      for Mac, Win, Linux.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              sorvig Morten Sørvig
              paeglis Gatis Paeglis
              Votes:
              2 Vote for this issue
              Watchers:
              14 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes