Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. SVG icons do not show up on the deployed app
QtWS25 Last Chance

SVG icons do not show up on the deployed app

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
22 Posts 6 Posters 11.7k 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.
  • H Offline
    H Offline
    hhoushiar
    wrote on last edited by
    #1

    So I am working on an application that I want to deploy on MacOS.
    I have compiled my code and I can run the app from QtCreator.
    I tried to deploy both manually and by using the macdeployqt.
    Everything gets copied and I can run the app.
    The problem is when I just run the app from the finder all my icons with SVG are not visible.
    But if I run the app from Terminal from inside the bundle like:

    cd ~/Desktop/Myapp.app/Contents
    ./MacOs/Myapp 
    

    Then it runs and the SVG icons are there.
    I have tried almost everything but I can't figure out what is the problem.
    I am using Qt 5.7.1 and running on MacOS 10.12.3

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      You are talking about SVG icons inside your application (in the gui), right? Do you pack them into your binary using QRC or use relative paths?

      (Z(:^

      1 Reply Last reply
      2
      • H Offline
        H Offline
        hhoushiar
        wrote on last edited by hhoushiar
        #3

        I am using QRC. And yes I am talking about the icons in the Gui.

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          Hm it has to work then... unless there is some problem loading SVG module - try saving logs to some file and inspect it.

          Or you open QRC via relative path and that fails.

          (Z(:^

          1 Reply Last reply
          1
          • VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by VRonin
            #5

            did you deploy the imageformats plugin qsvg.dll?

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            1 Reply Last reply
            1
            • H Offline
              H Offline
              hhoushiar
              wrote on last edited by
              #6

              If the path was wrong then how come the icons are there when I open the app from command line as I mentioned in my initial post but that also only works if I call it directly from my Contents directory.
              I also deployed the imageformats plugin but with libqsvg.dylib not qsvg.dll since I am deploying on the MacOS.

              sierdzioS 1 Reply Last reply
              0
              • H Offline
                H Offline
                hhoushiar
                wrote on last edited by
                #7

                I also tried DYLD_PRINT_LIBRARIES=1 and QT_DEBUG_PLUGINS=1 to see the libs and plugins that are getting used. But the SVG plugin gets called only when I run the app from terminal in the Contents directory.

                1 Reply Last reply
                0
                • H hhoushiar

                  If the path was wrong then how come the icons are there when I open the app from command line as I mentioned in my initial post but that also only works if I call it directly from my Contents directory.
                  I also deployed the imageformats plugin but with libqsvg.dylib not qsvg.dll since I am deploying on the MacOS.

                  sierdzioS Offline
                  sierdzioS Offline
                  sierdzio
                  Moderators
                  wrote on last edited by
                  #8

                  @hhoushiar said in SVG icons do not show up on the deployed app:

                  If the path was wrong then how come the icons are there when I open the app from command line as I mentioned in my initial post but that also only works if I call it directly from my Contents directory.

                  Current dir is different when you run from Contents that when you run the app from Finder. This can be mitigated by using QCoreApplication::applicationDirPath() to "anchor" your relative paths.

                  As said though, if you use QRC the standard way (compiled into app binary), paths cannot be a problem.

                  (Z(:^

                  1 Reply Last reply
                  0
                  • H Offline
                    H Offline
                    hhoushiar
                    wrote on last edited by
                    #9

                    One more thing when it fails to show the icons I get errors like:
                    QML Image: Error decoding: something.svg Unsupported image format
                    So I think the problem is that it cannot find the plugin.
                    But I don't know that else I have to add since the plugin is in the correct directory.
                    Should I modify something?

                    jsulmJ 1 Reply Last reply
                    0
                    • H hhoushiar

                      One more thing when it fails to show the icons I get errors like:
                      QML Image: Error decoding: something.svg Unsupported image format
                      So I think the problem is that it cannot find the plugin.
                      But I don't know that else I have to add since the plugin is in the correct directory.
                      Should I modify something?

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @hhoushiar Please read what @VRonin asked above

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      H 1 Reply Last reply
                      0
                      • jsulmJ jsulm

                        @hhoushiar Please read what @VRonin asked above

                        H Offline
                        H Offline
                        hhoushiar
                        wrote on last edited by
                        #11

                        @jsulm Thanks for your reply but I have already deployed the libqsvg.dylib in PlugIns/imageformats.
                        I am also using sql plugins and they are running without a problem. The problem is only with the SVG.
                        I have tried almost all the solutions that I could find online but unfortunately nothing has worked for me.

                        jsulmJ JKSHJ 2 Replies Last reply
                        0
                        • H hhoushiar

                          @jsulm Thanks for your reply but I have already deployed the libqsvg.dylib in PlugIns/imageformats.
                          I am also using sql plugins and they are running without a problem. The problem is only with the SVG.
                          I have tried almost all the solutions that I could find online but unfortunately nothing has worked for me.

                          jsulmJ Offline
                          jsulmJ Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          @hhoushiar can you execute "ldd libqsvg.dylib" on the target machine?

                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                          H 1 Reply Last reply
                          0
                          • jsulmJ jsulm

                            @hhoushiar can you execute "ldd libqsvg.dylib" on the target machine?

                            H Offline
                            H Offline
                            hhoushiar
                            wrote on last edited by
                            #13

                            @jsulm So the equivalent to "ldd" on MacOS is "otool -L" if I am not wrong.
                            and I execute this for libqsvg.dylib in my plugins and here is the output:

                            libqsvg.dylib:
                            	libqsvg.dylib (compatibility version 0.0.0, current version 0.0.0)
                            	@rpath/QtSvg.framework/Versions/5/QtSvg (compatibility version 5.7.0, current version 5.7.1)
                            	@rpath/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.7.0, current version 5.7.1)
                            	@rpath/QtGui.framework/Versions/5/QtGui (compatibility version 5.7.0, current version 5.7.1)
                            	@rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.7.0, current version 5.7.1)
                            	/System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration (compatibility version 1.0.0, current version 1.0.0)
                            	/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
                            	/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
                            	/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
                            	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
                            	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
                            

                            I also have the QtSvg, QtWidgets, QtGui and QtCore frameworks in Frameworks directory of my app bundle.

                            1 Reply Last reply
                            0
                            • H hhoushiar

                              @jsulm Thanks for your reply but I have already deployed the libqsvg.dylib in PlugIns/imageformats.
                              I am also using sql plugins and they are running without a problem. The problem is only with the SVG.
                              I have tried almost all the solutions that I could find online but unfortunately nothing has worked for me.

                              JKSHJ Offline
                              JKSHJ Offline
                              JKSH
                              Moderators
                              wrote on last edited by
                              #14

                              @hhoushiar said in SVG icons do not show up on the deployed app:

                              I have already deployed the libqsvg.dylib in PlugIns/imageformats

                              I don't know how things are done on macOS, but for Windows and Linux the path is <app>/imageformats/, not <app>/PlugIns/imageformats

                              Does the new location help?

                              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                              H 1 Reply Last reply
                              1
                              • JKSHJ JKSH

                                @hhoushiar said in SVG icons do not show up on the deployed app:

                                I have already deployed the libqsvg.dylib in PlugIns/imageformats

                                I don't know how things are done on macOS, but for Windows and Linux the path is <app>/imageformats/, not <app>/PlugIns/imageformats

                                Does the new location help?

                                H Offline
                                H Offline
                                hhoushiar
                                wrote on last edited by hhoushiar
                                #15

                                @JKSH said in SVG icons do not show up on the deployed app:

                                I don't know how things are done on macOS, but for Windows and Linux the path is <app>/imageformats/, not <app>/PlugIns/imageformats

                                Thanks for the reply but unfortunately that does not help. Under MacOS the app bundle structure should contain Frameworks to put all the libs, Plugins to put all the plugins and Resources to put the qml stuff.
                                I followed this based on the Qt documentation "Qt for macOS - Deployment". I am using QtSql.frmawork and sqldrivers plugins the same way and they work just fine. The problem is only with imageformats and SVG.

                                1 Reply Last reply
                                0
                                • H Offline
                                  H Offline
                                  hhoushiar
                                  wrote on last edited by
                                  #16

                                  Does anyone have any other idea?
                                  I really need to be able to deploy the app soon.
                                  I really appreciate any help.

                                  1 Reply Last reply
                                  0
                                  • VRoninV Offline
                                    VRoninV Offline
                                    VRonin
                                    wrote on last edited by
                                    #17

                                    There is a separate plugin for SVG icons, on windows it's iconengines/qsvgicons.dll did you deploy that one?

                                    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                                    ~Napoleon Bonaparte

                                    On a crusade to banish setIndexWidget() from the holy land of Qt

                                    H 1 Reply Last reply
                                    0
                                    • VRoninV VRonin

                                      There is a separate plugin for SVG icons, on windows it's iconengines/qsvgicons.dll did you deploy that one?

                                      H Offline
                                      H Offline
                                      hhoushiar
                                      wrote on last edited by
                                      #18

                                      @VRonin Thanks for your reply.
                                      Yeah I have that as well.
                                      Actually a few days ago I deployed the app under windows and I thought the MacOS should be easier and that was a big mistake.

                                      1 Reply Last reply
                                      0
                                      • H Offline
                                        H Offline
                                        hhoushiar
                                        wrote on last edited by
                                        #19

                                        Still not working.
                                        I don't know what is the difference between the SVG plugin and for example the platform or sql plugins.
                                        I tried to change the qt.conf file that did not help.
                                        Funny thing is if I don't copy the Qt stuff in the app bundle and let it use the frameworks and plugins directly from Qt installed directory it works but when I copy them into my app bundle it does not work.
                                        Is there a way to see what plugins the application tries to open and where it is looking for them?
                                        The QT_DEBUG_PLUGINS only outputs the plugins that it opens but it does not show the failed attempts.
                                        Or am I missing something here?

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

                                          Hi and welcome to devnet,

                                          What parameters are you giving to macdeployqt ?
                                          Can you also share your .pro file ?

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

                                          H 1 Reply Last reply
                                          1

                                          • Login

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