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. QSvgWidget, how to modify element
Forum Updated to NodeBB v4.3 + New Features

QSvgWidget, how to modify element

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 594 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.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by
    #1

    I have setup a resource for an SVG file. The SVG resource is rendered on the form using QSvgWidget, I want to access and change a colour in the SVG widget, can this be done with QSvgWidget?

    Kind Regards,
    Sy

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Nope. Its purely for Viewing.
      You can use XML parser to do it.
      https://stackoverflow.com/questions/15123544/change-the-color-of-an-svg-in-qt/33540671

      1 Reply Last reply
      2
      • SPlattenS Offline
        SPlattenS Offline
        SPlatten
        wrote on last edited by
        #3

        @mrjj , thank you, I figured this was the case, I'm now implementing code to do this using:
        https://cpp.hotexamples.com/examples/-/QSvgWidget/-/cpp-qsvgwidget-class-examples.html

        to aid.

        Kind Regards,
        Sy

        mrjjM 1 Reply Last reply
        1
        • SPlattenS SPlatten

          @mrjj , thank you, I figured this was the case, I'm now implementing code to do this using:
          https://cpp.hotexamples.com/examples/-/QSvgWidget/-/cpp-qsvgwidget-class-examples.html

          to aid.

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

          @SPlatten

          Well if you can tag the element you want with known ID it's much easier to find the right one.

          QDomElement element = elm.toElement();
          QString attribute = element.attribute("id");
             if(attribute == "tspan4167") { ....
          
          1 Reply Last reply
          1

          • Login

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