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. Changing colors of png icon in widget
Forum Updated to NodeBB v4.3 + New Features

Changing colors of png icon in widget

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 336 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.
  • R Offline
    R Offline
    Recursion
    wrote on last edited by
    #1

    Hi,

    I am just now delving into Qt Creator / Qt Quick and Qt Designer and had a question about creating custom widgets. In our application we want to give the user full control over the colors used on the UI widgets. For example if we had a speed gauge, the user should be able to change between a blue needle or red or yellow etc....

    I am looking at the Qt Designer examples and see for one of the gauge cluster examples that it has a png file of a red rpm needle. That rpm gauge in that example will cycle from green to orange to red as it moves through its full range but the needle always stays the same red color.

    So is there a way to programmatically change that red png needle to say a blue png needle on the fly? I know for sure that I could make a version of the png file in a number of different colors and those would be the only colors a user could choose from but its not ideal.

    Also is it possible to build a Qt application / widget and then swap out its assets after the fact. Like if I add a png file testImage.png can I have another program update/modify that png and then have the Qt application reload that widget on the fly? If so then this could be a workaround I could just write some code that can open a simple png file and change the color. Then I'd only have one png file but it could be any color.

    Thanks a lot!

    Christian EhrlicherC 1 Reply Last reply
    0
    • R Recursion

      Hi,

      I am just now delving into Qt Creator / Qt Quick and Qt Designer and had a question about creating custom widgets. In our application we want to give the user full control over the colors used on the UI widgets. For example if we had a speed gauge, the user should be able to change between a blue needle or red or yellow etc....

      I am looking at the Qt Designer examples and see for one of the gauge cluster examples that it has a png file of a red rpm needle. That rpm gauge in that example will cycle from green to orange to red as it moves through its full range but the needle always stays the same red color.

      So is there a way to programmatically change that red png needle to say a blue png needle on the fly? I know for sure that I could make a version of the png file in a number of different colors and those would be the only colors a user could choose from but its not ideal.

      Also is it possible to build a Qt application / widget and then swap out its assets after the fact. Like if I add a png file testImage.png can I have another program update/modify that png and then have the Qt application reload that widget on the fly? If so then this could be a workaround I could just write some code that can open a simple png file and change the color. Then I'd only have one png file but it could be any color.

      Thanks a lot!

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Recursion said in Changing colors of png icon in widget:

      So is there a way to programmatically change that red png needle to say a blue png needle on the fly? I know for sure that I could make a version of the png file in a number of different colors and those would be the only colors a user could choose from but its not ideal.

      You have to do it by your own by programatically changing the colors

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      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