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.4k 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.
  • 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