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. Dynamically change SVG color or replace a color by another one
QtWS25 Last Chance

Dynamically change SVG color or replace a color by another one

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 3 Posters 10.0k Views
  • 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.
  • D Offline
    D Offline
    DavidM29
    wrote on 7 Jun 2018, 14:41 last edited by
    #1

    Hello,

    I have a menu with SVG images. I would like to change their color on focus. My SVG are simple logo made of transparent and black for example this one : 0_1528382263831_83432629-095b-4931-9220-c1701fe15a86-image.png
    What I want is to replace the black color by white without having to handle many images.
    Is that possible ?
    I tried ColorOverlay but it also replace the transparent with white color.

    Thank you in advance

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bernd B
      wrote on 7 Jun 2018, 18:40 last edited by
      #2

      I think that will help you:
      https://forum.qt.io/topic/75115/qml-svg-change-color/6

      D 1 Reply Last reply 8 Jun 2018, 05:48
      1
      • B Bernd B
        7 Jun 2018, 18:40

        I think that will help you:
        https://forum.qt.io/topic/75115/qml-svg-change-color/6

        D Offline
        D Offline
        DavidM29
        wrote on 8 Jun 2018, 05:48 last edited by
        #3

        @Bernd-B
        I tried to use ColorOverlay but it make the transparent color turn to white also. And I don't want that. I wan't to turn black into white only.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          markugra
          wrote on 11 Jun 2018, 18:00 last edited by
          #4

          Hi, I have no problems to color my svg files white with the approach mentioned by Bernd. Maybe the problem is in the format of your svg file (I had some problems with svg that contained groups or masks etc). To test that you could try a file from: https://material.io/tools/icons/?style=baseline
          those usually work for me

          1 Reply Last reply
          2
          • D Offline
            D Offline
            DavidM29
            wrote on 12 Jun 2018, 05:57 last edited by
            #5

            Thank you for that answer, I believe is due to the device I'm trying to run it on, because on the computer it works quite good.
            I hoped to have an other solution than this one. I will have to manage many images.

            1 Reply Last reply
            0

            4/5

            11 Jun 2018, 18:00

            • Login

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