Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Change element in SVG

Change element in SVG

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 3 Posters 561 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.
  • P Offline
    P Offline
    poucz
    wrote on last edited by
    #1

    Hello,
    I need refresh data in svg element - for example time in time box.

    To do this, i wrote C++ class with interface that change data in svg (in xml file) and this class have Q_PROPERTY (QString svgData).
    In QML I have this image:

     Image {
            source: 'data:image/svg+xml;utf8,'+svgFile.svgData
     }
    

    This work, but when svgData is changed image is refresh with blank glitch image (So image is generate right but It seems that re-render image first erase old data and than write new data).

    My question Is what is best way to change some text (defined by id) in svg?

    jsulmJ JKSHJ 2 Replies Last reply
    0
    • P poucz

      Hello,
      I need refresh data in svg element - for example time in time box.

      To do this, i wrote C++ class with interface that change data in svg (in xml file) and this class have Q_PROPERTY (QString svgData).
      In QML I have this image:

       Image {
              source: 'data:image/svg+xml;utf8,'+svgFile.svgData
       }
      

      This work, but when svgData is changed image is refresh with blank glitch image (So image is generate right but It seems that re-render image first erase old data and than write new data).

      My question Is what is best way to change some text (defined by id) in svg?

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #3

      @poucz said in Change element in SVG:

      what is best way to change some text (defined by id) in svg?

      Unfortunately, Qt does not have proper support for dynamically updating individual elements of an SVG file. As you have discovered, you need to reload the whole SVG image if you change an element.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      P 1 Reply Last reply
      1
      • P poucz

        Hello,
        I need refresh data in svg element - for example time in time box.

        To do this, i wrote C++ class with interface that change data in svg (in xml file) and this class have Q_PROPERTY (QString svgData).
        In QML I have this image:

         Image {
                source: 'data:image/svg+xml;utf8,'+svgFile.svgData
         }
        

        This work, but when svgData is changed image is refresh with blank glitch image (So image is generate right but It seems that re-render image first erase old data and than write new data).

        My question Is what is best way to change some text (defined by id) in svg?

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

        @poucz said in Change element in SVG:

        So image is generate right

        Did you verify that? Maybe the SVG is invalid after your modification?

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

        1 Reply Last reply
        0
        • P poucz

          Hello,
          I need refresh data in svg element - for example time in time box.

          To do this, i wrote C++ class with interface that change data in svg (in xml file) and this class have Q_PROPERTY (QString svgData).
          In QML I have this image:

           Image {
                  source: 'data:image/svg+xml;utf8,'+svgFile.svgData
           }
          

          This work, but when svgData is changed image is refresh with blank glitch image (So image is generate right but It seems that re-render image first erase old data and than write new data).

          My question Is what is best way to change some text (defined by id) in svg?

          JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #3

          @poucz said in Change element in SVG:

          what is best way to change some text (defined by id) in svg?

          Unfortunately, Qt does not have proper support for dynamically updating individual elements of an SVG file. As you have discovered, you need to reload the whole SVG image if you change an element.

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          P 1 Reply Last reply
          1
          • JKSHJ JKSH

            @poucz said in Change element in SVG:

            what is best way to change some text (defined by id) in svg?

            Unfortunately, Qt does not have proper support for dynamically updating individual elements of an SVG file. As you have discovered, you need to reload the whole SVG image if you change an element.

            P Offline
            P Offline
            poucz
            wrote on last edited by
            #4

            @JKSH
            Thank you for confirming my assumptions

            1 Reply Last reply
            0
            • P poucz has marked this topic as solved on

            • Login

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