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
QtWS25 Last Chance

How to use SVG

Scheduled Pinned Locked Moved Unsolved General and Desktop
svgiconwidget
33 Posts 7 Posters 16.8k 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.
  • mrjjM mrjj

    @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 ?

    SavizS Offline
    SavizS Offline
    Saviz
    wrote on last edited by Saviz
    #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?)

    JoeCFDJ 1 Reply Last reply
    0
    • SavizS Saviz

      @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?)

      JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by JoeCFD
      #18

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

      SavizS 1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on 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
        • JoeCFDJ Offline
          JoeCFDJ Offline
          JoeCFD
          wrote on last edited by JoeCFD
          #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.

          SavizS 1 Reply Last reply
          0
          • JoeCFDJ JoeCFD

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

            SavizS Offline
            SavizS Offline
            Saviz
            wrote on last edited by Saviz
            #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
            • JoeCFDJ JoeCFD

              @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.

              SavizS Offline
              SavizS Offline
              Saviz
              wrote on 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?

              mrjjM 1 Reply Last reply
              0
              • SavizS Saviz

                @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?

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by mrjj
                #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

                SavizS 1 Reply Last reply
                0
                • mrjjM mrjj

                  @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

                  SavizS Offline
                  SavizS Offline
                  Saviz
                  wrote on last edited by Saviz
                  #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

                  mrjjM 1 Reply Last reply
                  0
                  • SavizS Saviz

                    @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

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on 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.

                    SavizS 1 Reply Last reply
                    1
                    • mrjjM mrjj

                      @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.

                      SavizS Offline
                      SavizS Offline
                      Saviz
                      wrote on 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?

                      mrjjM 1 Reply Last reply
                      0
                      • SavizS Saviz

                        @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?

                        mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on 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.

                        SavizS 1 Reply Last reply
                        2
                        • mrjjM mrjj

                          @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.

                          SavizS Offline
                          SavizS Offline
                          Saviz
                          wrote on 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?

                          mrjjM 1 Reply Last reply
                          0
                          • SavizS Saviz

                            @mrjj

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

                            mrjjM Offline
                            mrjjM Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on last edited by mrjj
                            #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.

                            SavizS 1 Reply Last reply
                            1
                            • mrjjM mrjj

                              @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.

                              SavizS Offline
                              SavizS Offline
                              Saviz
                              wrote on last edited by Saviz
                              #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 :) )

                              mrjjM 1 Reply Last reply
                              0
                              • SavizS Saviz

                                @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 :) )

                                mrjjM Offline
                                mrjjM Offline
                                mrjj
                                Lifetime Qt Champion
                                wrote on last edited by
                                #31

                                @Saviz
                                Hi
                                What you mean with custom widget for SVG ?

                                You mean your own classed based on QSvgWidget ?

                                Or to simply use QSvgWidget ?

                                1 Reply Last reply
                                0
                                • L Offline
                                  L Offline
                                  Labidi Ahmed
                                  wrote on last edited by
                                  #32

                                  So i am using Qt 6.2.2 & ran into the same problem the solution was :

                                  in the .pro file its QT+= svg svgwidgets
                                  now you can

                                  #include <QSvgWidgets>
                                  

                                  found it in the included svgviewer example in QT qtsvg-svgviewer-example

                                  hope i helped

                                  1 Reply Last reply
                                  2
                                  • SMEasyS Offline
                                    SMEasyS Offline
                                    SMEasy
                                    wrote on last edited by
                                    #33

                                    As explained here, QSvgWidget has been moved to a new module called QtSvgWidgets. According to the documentation:

                                    Header: #include <QSvgWidget>
                                    CMake: find_package(Qt6 REQUIRED COMPONENTS SvgWidgets) target_link_libraries(mytarget PRIVATE Qt6::SvgWidgets)
                                    qmake: QT += svgwidgets
                                    Inherits: QWidget

                                    So in Qt6 the solution is following:

                                    QT += svgwidgets
                                    
                                    1 Reply Last reply
                                    2

                                    • Login

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