[Qt-interest] svg plugin not loaded

Andrew Maclean andrew.amaclean at gmail.com
Tue Dec 1 05:11:12 CET 2009


Create a directory called plugins/imageformats (in the same directory
as your executable) with the svg plugins in it.
Then in your code

Create a function like this:

//! Find and load a translation file.
/*!
 *
 *  @param translator - the translator.
 */
void PluginLoader(QDir & pluginsDir)
{
  // Plugins
  pluginsDir = QDir(qApp->applicationDirPath());

  #if defined(Q_OS_WIN)
     if (pluginsDir.dirName().toLower() == "debug" ||
pluginsDir.dirName().toLower() == "release")
         pluginsDir.cdUp();
  #elif defined(Q_OS_MAC)
     if (pluginsDir.dirName() == "MacOS")
     {
         pluginsDir.cdUp();
         pluginsDir.cdUp();
         pluginsDir.cdUp();
     }
  #endif
  pluginsDir.setPath( pluginsDir.absolutePath() + "/plugins");
}

and in main:
  QDir pluginsDir;
  PluginLoader(pluginsDir);
  QStringList libPaths;
  // Append the local plugin path to the qApp library paths
  if ( pluginsDir.exists() )
  {
    libPaths << pluginsDir.absolutePath() << qApp->libraryPaths();
    qApp->setLibraryPaths(libPaths);
  }


This should append the plugins path to wherever you put it.

I hope this helps.

Regards
Andrew


On Tue, Dec 1, 2009 at 10:19 AM, Bryce Allen <qt at bda.ath.cx> wrote:
> I am trying to run the systray example on a Windows XP machine without
> qt installed by placing the proper DLLs in the application directory. I
> built the app with Qt Creater 1.2.1 (qt 4.5.3) and release build config,
> and my app dir looks like this:
>
> systray.exe
> QtCore4.dll
> QtGui4.dll
> QtXml4.dll
> iconengines\qsvgicon4.dll
> imageformats\qsvg4.dll
>
> I have read the documentation and some relevant posts in the archives,
> and this looks like the correct locations for the dlls. However
> when I run the app the svg icons are missing. I tried setting
> QT_DEBUG_PLUGINS=1 and running systray.exe from cmd, but no debug info
> is displayed.
>
> I also checked QImageReader::supportedImageFormats() and svg is not in
> the list, so it appears that it's really a problem with loading the svg
> plugin and not with finding the image data. Any ideas?
>
> Thanks,
> Bryce
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>



-- 
___________________________________________
Andrew J. P. Maclean
Centre for Autonomous Systems
The Rose Street Building J04
The University of Sydney  2006  NSW
AUSTRALIA
Ph: +61 2 9351 3283
Fax: +61 2 9351 7474
URL: http://www.acfr.usyd.edu.au/
___________________________________________



More information about the Qt-interest-old mailing list