Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QPixmap not read svg
Forum Updated to NodeBB v4.3 + New Features

QPixmap not read svg

Scheduled Pinned Locked Moved Solved General and Desktop
14 Posts 3 Posters 1.5k 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.
  • M Mikeeeeee

    Hi!
    In Ubuntu 20 QPixmap read svg, but in Windoes 10 QPixmap not read svg. Why? How QPixmap can read svg-file?

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

    @Mikeeeeee How did you install Qt on Windows? How do you read SVG (show code)?

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

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Mikeeeeee
      wrote on last edited by
      #3

      I use PyQt, I install conda and after install pyqt in conda. This code work in Ubuntu 20:

              labelLogo = QLabel()
              pixmap = QPixmap("./images/logo.svg")
              pixmap = pixmap.scaled(200,200, QtCore.Qt.KeepAspectRatio)
              labelLogo.setPixmap(pixmap)
      
      jsulmJ JoeCFDJ 2 Replies Last reply
      0
      • M Mikeeeeee

        I use PyQt, I install conda and after install pyqt in conda. This code work in Ubuntu 20:

                labelLogo = QLabel()
                pixmap = QPixmap("./images/logo.svg")
                pixmap = pixmap.scaled(200,200, QtCore.Qt.KeepAspectRatio)
                labelLogo.setPixmap(pixmap)
        
        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #4

        @Mikeeeeee said in QPixmap not read svg:

        ./images/logo.svg

        this is a relative path. You should at least check whether pixmap is null or not: https://doc.qt.io/qt-5/qpixmap.html#isNull
        Also, check whether you have the SVG plug-in: plugins/imageformats/libqsvg.so

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

        M 1 Reply Last reply
        2
        • jsulmJ jsulm

          @Mikeeeeee said in QPixmap not read svg:

          ./images/logo.svg

          this is a relative path. You should at least check whether pixmap is null or not: https://doc.qt.io/qt-5/qpixmap.html#isNull
          Also, check whether you have the SVG plug-in: plugins/imageformats/libqsvg.so

          M Offline
          M Offline
          Mikeeeeee
          wrote on last edited by
          #5

          @jsulm but this work:

          pixmap = QPixmap("./images/logo.png")
          

          And I use Windows 10, Windows haven't .so. In conda I haven't file libqsvg. Hwot me need to do?

          jsulmJ 1 Reply Last reply
          0
          • M Mikeeeeee

            @jsulm but this work:

            pixmap = QPixmap("./images/logo.png")
            

            And I use Windows 10, Windows haven't .so. In conda I haven't file libqsvg. Hwot me need to do?

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

            @Mikeeeeee said in QPixmap not read svg:

            Hwot me need to do?

            Search for *svg* in your PyQt set-up...

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

            1 Reply Last reply
            0
            • M Offline
              M Offline
              Mikeeeeee
              wrote on last edited by
              #7

              I have only SVGExporter.py in pyqtgraph

              jsulmJ 1 Reply Last reply
              0
              • M Mikeeeeee

                I have only SVGExporter.py in pyqtgraph

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

                @Mikeeeeee So, no qsvg.dll? If so, then that's the reason why you can't load SVG images.

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

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  Mikeeeeee
                  wrote on last edited by
                  #9

                  What should I do? How can I add the desired library to the сonda?

                  jsulmJ 1 Reply Last reply
                  0
                  • M Mikeeeeee

                    What should I do? How can I add the desired library to the сonda?

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

                    @Mikeeeeee Maybe you need to install the SVG plug-in? I never used conda, so check whether this plug-in requires an additional package to be installed.

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

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      Mikeeeeee
                      wrote on last edited by
                      #11

                      @jsulm said in QPixmap not read svg:

                      SVG plug-in

                      What is the correct name of this plugin?

                      jsulmJ 1 Reply Last reply
                      0
                      • M Mikeeeeee

                        I use PyQt, I install conda and after install pyqt in conda. This code work in Ubuntu 20:

                                labelLogo = QLabel()
                                pixmap = QPixmap("./images/logo.svg")
                                pixmap = pixmap.scaled(200,200, QtCore.Qt.KeepAspectRatio)
                                labelLogo.setPixmap(pixmap)
                        
                        JoeCFDJ Offline
                        JoeCFDJ Offline
                        JoeCFD
                        wrote on last edited by JoeCFD
                        #12

                        @Mikeeeeee wrong way to load svg because you may lose resolution. You never scale a svg picture.
                        QPixmap * pixmap = new QPixmap( QSize( 200, 200 ) );
                        pixmap->fill( Qt::transparent );
                        paint pixmap with svg engine.

                        1 Reply Last reply
                        0
                        • M Mikeeeeee

                          @jsulm said in QPixmap not read svg:

                          SVG plug-in

                          What is the correct name of this plugin?

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

                          @Mikeeeeee said in QPixmap not read svg:

                          What is the correct name of this plugin?

                          I already gave it you before: qsvg.dll

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

                          1 Reply Last reply
                          1
                          • M Offline
                            M Offline
                            Mikeeeeee
                            wrote on last edited by
                            #14

                            I reinstall conda and after its work

                            1 Reply Last reply
                            0

                            • Login

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