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. formatting .svg files?

formatting .svg files?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 502 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.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by
    #1

    Hi all -

    I've been given a bunch of .svg files like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
        <title>icon/alert/warning_24px_sharp</title>
        <defs>
            <path d="M1,21.5 L23,21.5 L12,2.5 L1,21.5 Z M13,18.5 L11,18.5 L11,16.5 L13,16.5 L13,18.5 Z M13,14.5 L11,14.5 L11,10.5 L13,10.5 L13,14.5 Z" id="path-1"></path>
        </defs>
        <g id="icon/alert/warning_24px" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
            <mask id="mask-2" fill="white">
                <use xlink:href="#path-1"></use>
            </mask>
            <use fill="#000000" fill-rule="nonzero" xlink:href="#path-1"></use>
        </g>
    </svg>
    

    Which produces something like the black triangle in this picture:warning.PNG
    Is it possible to manipulate this file, using QML (not editing the file) to change the triangle's color?

    Thanks...

    1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by
      #2

      Maybe
      ColorOverlay
      or
      SvgPath

      The problem with path is you have to provide the svg string instead of file.

      C++ is a perfectly valid school of magic.

      mzimmersM 1 Reply Last reply
      1
      • fcarneyF fcarney

        Maybe
        ColorOverlay
        or
        SvgPath

        The problem with path is you have to provide the svg string instead of file.

        mzimmersM Offline
        mzimmersM Offline
        mzimmers
        wrote on last edited by
        #3

        @fcarney DAMN you're good:

                  Image {
                    id: menuButtonIcon
                    source: root.iconWarning
                    anchors.right: reagentButton2.right
                    anchors.rightMargin: (buttonWidth * 0.1)
                    anchors.verticalCenter: parent.verticalCenter
        
                    width: reagentButton2.icon.width
                    height: reagentButton2.icon.height
                  }
                  ColorOverlay {
                         anchors.fill: menuButtonIcon
                         source: menuButtonIcon
                         color: rootBgColor // this is white
                     }
        

        produces:
        warning.PNG
        That's a really useful component; IMO it deserves mention in the Image documentation.

        This is going to save us a lot of work...thanks!

        fcarneyF 1 Reply Last reply
        1
        • mzimmersM mzimmers

          @fcarney DAMN you're good:

                    Image {
                      id: menuButtonIcon
                      source: root.iconWarning
                      anchors.right: reagentButton2.right
                      anchors.rightMargin: (buttonWidth * 0.1)
                      anchors.verticalCenter: parent.verticalCenter
          
                      width: reagentButton2.icon.width
                      height: reagentButton2.icon.height
                    }
                    ColorOverlay {
                           anchors.fill: menuButtonIcon
                           source: menuButtonIcon
                           color: rootBgColor // this is white
                       }
          

          produces:
          warning.PNG
          That's a really useful component; IMO it deserves mention in the Image documentation.

          This is going to save us a lot of work...thanks!

          fcarneyF Offline
          fcarneyF Offline
          fcarney
          wrote on last edited by
          #4

          @mzimmers said in formatting .svg files?:

          IMO it deserves mention in the Image documentation.

          Look in the Graphical Effects part of QML docs. Lots of neat toys in there.
          I wanted a crosshair that showed up regardless of background color. I was able to do this with some graphical effects. It basically took the original image area under crosshair and convert it to be a contrast value. Its almost like a photo negative effect.

          C++ is a perfectly valid school of magic.

          1 Reply Last reply
          0

          • Login

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