Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVG icons not showing up in Qt4 release build in windows

I have a Qt4 application with SVG icons, compiled with mingw (in windows), linked to Qt shared libraries.

When application is run, SVG icons show up in debug and release builds in linux, however in windows SVG icons show up only in debug build but not in release build.

All SVG icons are listed in project.qrc, and project.pro has RESOURCES = project.qrc. Application uses QtSvg4.dll (version 4.7.0).

Qt 4.7.0, Qt Creator 2.0.1, mingw/g++ 4.4.0.

Solution update: In application directory, create /imageformats/ directory and put qsvg4.dll there instead of application directory itself, or create a qt.conf file with appropriate path. More information in deploying plugins.

like image 896
vls Avatar asked Nov 30 '10 21:11

vls


People also ask

Can SVG files be used as icons?

Scalable Vector Graphics, or SVGs, are a generally a good choice for use as icons on your website, because they are vector graphics. Vector graphics can be scaled to any size without losing quality. The files are small and compress well, so they won't make your website slow to load.

Does Qt support SVG?

Qt supports the static features of SVG 1.2 Tiny. ECMA scripts and DOM manipulation are currently not supported. SVG drawings can be rendered onto any QPaintDevice subclass.

How use SVG icons?

SVG images can be written directly into the HTML document using the <svg> </svg> tag. To do this, open the SVG image in VS code or your preferred IDE, copy the code, and paste it inside the <body> element in your HTML document. If you did everything correctly, your webpage should look exactly like the demo below.


3 Answers

for Qt 5.14 add a line to the .pro file

QT       += svg
like image 134
xitong Avatar answered Oct 28 '22 09:10

xitong


For Qt5

Since Qt5 the framework has been heavily modularized (List of Modules). Most likely you are missing the svg module. The application will still compile without complaining. Make sure the SVG module is installed on your system and linked (with qmake (Howto), cmake (Howto) or plain make). If it was linked successfully QImageReader::supportedImageFormats() will list SVG.

like image 40
ManuelSchneid3r Avatar answered Oct 28 '22 10:10

ManuelSchneid3r


Most likely you will have to include the plugins from your qt dir. This involves making a qt.conf file that is local to your app (see here: http://doc.qt.io/qt-4.8/qt-conf.html , more specifically the [Paths] section), and copy c:\Qt\4.x.x\plugins\imageformats*.dll to your distributable's directory.

like image 43
Chris Avatar answered Oct 28 '22 11:10

Chris