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 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
                  • S Saviz
                    3 Jul 2021, 12:56

                    @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 Offline
                    M Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on 3 Jul 2021, 22:09 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 2 May 2022, 13:37 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 12 Feb 2023, 20:06 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