Changing colors of png icon in widget
-
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!
-
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!
@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