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. How to use SVG
Forum Updated to NodeBB v4.3 + New Features

How to use SVG

Scheduled Pinned Locked Moved Unsolved General and Desktop
svgiconwidget
33 Posts 7 Posters 17.9k Views 2 Watching
  • 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.
  • S Offline
    S Offline
    SGaist
    Lifetime Qt Champion
    wrote on 2 Jul 2021, 12:02 last edited by
    #11

    Which version of Qt are you currently using ?

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

    S 1 Reply Last reply 2 Jul 2021, 16:27
    1
    • S Saviz
      2 Jul 2021, 11:48

      @jsulm

      In the qmake .pro file that @mrjj kindly shared, in front of the "greaterThan(QT_MAJOR_VERSION, 4):" there was "QT += widgets svg" and that is what I did. I also tried adding the "QT += svg" to the top, but that did not do the trick.

      M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 2 Jul 2021, 12:05 last edited by
      #12

      @Saviz

      Hi
      it should work unless really old Qt.

      Could you try in build menu to use Clean all, run qmake and then press the run ?

      S 1 Reply Last reply 2 Jul 2021, 17:30
      0
      • S SGaist
        2 Jul 2021, 12:02

        Which version of Qt are you currently using ?

        S Offline
        S Offline
        Saviz
        wrote on 2 Jul 2021, 16:27 last edited by Saviz 7 Feb 2021, 16:34
        #13

        @SGaist

        Qt version 4.14.2 (That is what it says in the "About")

        I don't understand something, I just recently downloaded Qt. When I downloaded Qt I selected the Qt 6 version but now as you told me to look at the version it says 4.14,2. What is going on I am very confused. Did I make a mistake in the download process?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 2 Jul 2021, 16:47 last edited by
          #14

          No that's the Qt Creator version. There's no Qt 4.14.

          You have to take a look at the kit you are using.

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

          S 1 Reply Last reply 2 Jul 2021, 16:50
          0
          • S SGaist
            2 Jul 2021, 16:47

            No that's the Qt Creator version. There's no Qt 4.14.

            You have to take a look at the kit you are using.

            S Offline
            S Offline
            Saviz
            wrote on 2 Jul 2021, 16:50 last edited by
            #15

            @SGaist

            I took a look at the kit as you instructed.

            The kit version is: Qt 6.0.3 64bit

            1 Reply Last reply
            0
            • J Offline
              J Offline
              JoeCFD
              wrote on 2 Jul 2021, 17:07 last edited by JoeCFD 7 Feb 2021, 17:16
              #16

              It was introduced from 4.1.
              https://doc.qt.io/qt-5/qsvgwidget.html
              QT += core gui widgets svg <=== you need widgets as well for qsvgwidget

              If you simply need a QPixmap from a svg source for other widgets, use QSvgRenderer to paint one.

              1 Reply Last reply
              0
              • M mrjj
                2 Jul 2021, 12:05

                @Saviz

                Hi
                it should work unless really old Qt.

                Could you try in build menu to use Clean all, run qmake and then press the run ?

                S Offline
                S Offline
                Saviz
                wrote on 2 Jul 2021, 17:30 last edited by Saviz 7 Feb 2021, 17:30
                #17

                @mrjj

                I tried doing what you suggested. Unfortunately it didn't work.

                I first cleaned the project and then ran qmake but I still get the same errors.
                Maybe I am doing something else wrong? (Like not including something?)

                J 1 Reply Last reply 2 Jul 2021, 17:44
                0
                • S Saviz
                  2 Jul 2021, 17:30

                  @mrjj

                  I tried doing what you suggested. Unfortunately it didn't work.

                  I first cleaned the project and then ran qmake but I still get the same errors.
                  Maybe I am doing something else wrong? (Like not including something?)

                  J Offline
                  J Offline
                  JoeCFD
                  wrote on 2 Jul 2021, 17:44 last edited by JoeCFD 7 Feb 2021, 17:47
                  #18

                  @Saviz CONFIG += c++17 you also need 17 for Qt 6.
                  Show this line of your Makefile:
                  LIBS = $(SUBLIBS)
                  it should have -lQt5Svg

                  S 1 Reply Last reply 3 Jul 2021, 04:30
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 2 Jul 2021, 18:02 last edited by
                    #19

                    Drop the C++ CONFIG, you do not need that currently.

                    You should also consider updating to the latest Qt 6.1.

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

                    1 Reply Last reply
                    0
                    • J Offline
                      J Offline
                      JoeCFD
                      wrote on 2 Jul 2021, 18:14 last edited by JoeCFD 7 Feb 2021, 18:29
                      #20

                      @Saviz Another possibility is svg is not installed. Run MaintenaceTool to add it. I just installed Qt 6.1.2 in which svg is included. If you can find it in the Qt lib dir, check the path settings for Qt.

                      S 1 Reply Last reply 3 Jul 2021, 05:03
                      0
                      • J JoeCFD
                        2 Jul 2021, 17:44

                        @Saviz CONFIG += c++17 you also need 17 for Qt 6.
                        Show this line of your Makefile:
                        LIBS = $(SUBLIBS)
                        it should have -lQt5Svg

                        S Offline
                        S Offline
                        Saviz
                        wrote on 3 Jul 2021, 04:30 last edited by Saviz 7 Mar 2021, 04:31
                        #21

                        @JoeCFD

                        I don't see this line in my qmake file. Maybe that is the reason it doesn't work. Should I add it?

                        1 Reply Last reply
                        0
                        • J JoeCFD
                          2 Jul 2021, 18:14

                          @Saviz Another possibility is svg is not installed. Run MaintenaceTool to add it. I just installed Qt 6.1.2 in which svg is included. If you can find it in the Qt lib dir, check the path settings for Qt.

                          S Offline
                          S Offline
                          Saviz
                          wrote on 3 Jul 2021, 05:03 last edited by
                          #22

                          @JoeCFD said in How to use SVG:

                          MaintenaceTool

                          If I want to only install the SVG components, then what component do I have to select in the MaintenaceTool to install?

                          M 1 Reply Last reply 3 Jul 2021, 05:12
                          0
                          • S Saviz
                            3 Jul 2021, 05:03

                            @JoeCFD said in How to use SVG:

                            MaintenaceTool

                            If I want to only install the SVG components, then what component do I have to select in the MaintenaceTool to install?

                            M Offline
                            M Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on 3 Jul 2021, 05:12 last edited by mrjj 7 Mar 2021, 05:13
                            #23

                            @Saviz

                            Hi

                            It should be included in any of the installer options. Its not a standalone option.

                            I don't have Qt6 to test with.

                            So the project I linked cannot run under Qt6 ?

                            complains about svg ?

                            Try install the Qt 6.1.2 as @JoeCFD suggests

                            S 1 Reply Last reply 3 Jul 2021, 05:43
                            0
                            • M mrjj
                              3 Jul 2021, 05:12

                              @Saviz

                              Hi

                              It should be included in any of the installer options. Its not a standalone option.

                              I don't have Qt6 to test with.

                              So the project I linked cannot run under Qt6 ?

                              complains about svg ?

                              Try install the Qt 6.1.2 as @JoeCFD suggests

                              S Offline
                              S Offline
                              Saviz
                              wrote on 3 Jul 2021, 05:43 last edited by Saviz 7 Mar 2021, 05:53
                              #24

                              @mrjj

                              I will give it a try. But my speed is not the best. It may take a while to download the new version. But I will report back how it went. Thank you all for your help

                              M 1 Reply Last reply 3 Jul 2021, 06:25
                              0
                              • S Saviz
                                3 Jul 2021, 05:43

                                @mrjj

                                I will give it a try. But my speed is not the best. It may take a while to download the new version. But I will report back how it went. Thank you all for your help

                                M Offline
                                M Offline
                                mrjj
                                Lifetime Qt Champion
                                wrote on 3 Jul 2021, 06:25 last edited by
                                #25

                                @Saviz

                                Hi
                                Else a sure bet is installing Qt5.15.
                                While v6 does offer new things
                                https://wiki.qt.io/New_Features_in_Qt_6.0
                                Its mostly if you are using QML and it still has lots of features missing planned
                                for some later releases.

                                S 1 Reply Last reply 3 Jul 2021, 09:01
                                1
                                • M mrjj
                                  3 Jul 2021, 06:25

                                  @Saviz

                                  Hi
                                  Else a sure bet is installing Qt5.15.
                                  While v6 does offer new things
                                  https://wiki.qt.io/New_Features_in_Qt_6.0
                                  Its mostly if you are using QML and it still has lots of features missing planned
                                  for some later releases.

                                  S Offline
                                  S Offline
                                  Saviz
                                  wrote on 3 Jul 2021, 09:01 last edited by
                                  #26

                                  @mrjj

                                  Okay, I will try it. By the way I have one last question. Why isn't there a widget for SVG in QT Designer by default?

                                  M 1 Reply Last reply 3 Jul 2021, 09:08
                                  0
                                  • S Saviz
                                    3 Jul 2021, 09:01

                                    @mrjj

                                    Okay, I will try it. By the way I have one last question. Why isn't there a widget for SVG in QT Designer by default?

                                    M Offline
                                    M Offline
                                    mrjj
                                    Lifetime Qt Champion
                                    wrote on 3 Jul 2021, 09:08 last edited by
                                    #27

                                    @Saviz

                                    • Why isn't there a widget for SVG in QT Designer by default?

                                    Too much work I would guess. To allow a Widget to be used in design time, a plugin must be made and maintained across many Designers.
                                    And QSvgWidget doesn't have any properties to set at Design time. (besides the svg file) so I gues sit was
                                    not worth the effort.

                                    You can use the Producer Promote feature to allow a Qwidget as a place holder in Designer and then app is run its
                                    the SVG one.

                                    S 1 Reply Last reply 3 Jul 2021, 11:56
                                    2
                                    • M mrjj
                                      3 Jul 2021, 09:08

                                      @Saviz

                                      • Why isn't there a widget for SVG in QT Designer by default?

                                      Too much work I would guess. To allow a Widget to be used in design time, a plugin must be made and maintained across many Designers.
                                      And QSvgWidget doesn't have any properties to set at Design time. (besides the svg file) so I gues sit was
                                      not worth the effort.

                                      You can use the Producer Promote feature to allow a Qwidget as a place holder in Designer and then app is run its
                                      the SVG one.

                                      S Offline
                                      S Offline
                                      Saviz
                                      wrote on 3 Jul 2021, 11:56 last edited by
                                      #28

                                      @mrjj

                                      Very interesting. Is there a documentation that I can use for the Producer Promote feature so I can learn it?

                                      M 1 Reply Last reply 3 Jul 2021, 12:31
                                      0
                                      • S Saviz
                                        3 Jul 2021, 11:56

                                        @mrjj

                                        Very interesting. Is there a documentation that I can use for the Producer Promote feature so I can learn it?

                                        M Offline
                                        M Offline
                                        mrjj
                                        Lifetime Qt Champion
                                        wrote on 3 Jul 2021, 12:31 last edited by mrjj 7 Mar 2021, 12:32
                                        #29

                                        @Saviz

                                        Hi
                                        Its very handy.

                                        In your use case you place a QWidget on the form, right-click and choose to promote.
                                        Then tell it QSvgWidget for class name and it will guess on QSvgWidget.h
                                        Then press Add (+), then then promote.

                                        https://doc.qt.io/qt-5/designer-using-custom-widgets.html

                                        https://stackoverflow.com/questions/33588289/what-is-promote-to-feature-in-qt-creator-and-how-does-it-work

                                        Do note:
                                        Accessing it via Ui-> is possible and you can call the real functions from code, just like any other widget.

                                        S 1 Reply Last reply 3 Jul 2021, 12:56
                                        1
                                        • M mrjj
                                          3 Jul 2021, 12:31

                                          @Saviz

                                          Hi
                                          Its very handy.

                                          In your use case you place a QWidget on the form, right-click and choose to promote.
                                          Then tell it QSvgWidget for class name and it will guess on QSvgWidget.h
                                          Then press Add (+), then then promote.

                                          https://doc.qt.io/qt-5/designer-using-custom-widgets.html

                                          https://stackoverflow.com/questions/33588289/what-is-promote-to-feature-in-qt-creator-and-how-does-it-work

                                          Do note:
                                          Accessing it via Ui-> is possible and you can call the real functions from code, just like any other widget.

                                          S Offline
                                          S Offline
                                          Saviz
                                          wrote on 3 Jul 2021, 12:56 last edited by Saviz 7 Mar 2021, 12:57
                                          #30

                                          @mrjj

                                          So, if I want to create a custom widget for SVG, how can I do that? Is there an example that I can follow for promoting a widget to SVG?

                                          (I ask this because I really want to use SVG as default and I need a solution.)
                                          (I am also a beginner so I have no idea where to start :) )

                                          M 1 Reply Last reply 3 Jul 2021, 22:09
                                          0

                                          20/33

                                          2 Jul 2021, 18:14

                                          • Login

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