Hi!
QIcon have Mode { Normal, Disabled, Active, Selected }
I need average color between Disabled (grayed out) and Selected (blued out).
Can i create my mode with my render or change any mode?
Screenshot:
scr1.jpg
Thanks.
Hi!
QIcon have Mode { Normal, Disabled, Active, Selected }
I need average color between Disabled (grayed out) and Selected (blued out).
Can i create my mode with my render or change any mode?
Screenshot:
scr1.jpg
Thanks.
Last edited by Borland; 15th March 2012 at 14:01.
If you know how to subclass, sure.Can i create my mode with my render or change any mode?
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
Sorry, i don't understand how i can change color.
I am not clear on what you question is about?
Is it about how to change a color in an image, or how to extend QIcon to have more modes?
Please ask clear and specific question, and not force us to play 20 questions with you to figure out what you want.
http://www.catb.org/~esr/faqs/smart-questions.html
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
i'm sorry that my question not specific.
Standart modes for QIcon:
Disabled:
MaximumDisabled.png
Active:
MaximumActive.jpg
I need to create my specific mode
MyDisable:
MaximumAverage.png
I hope you can help me understand how to do it.
You still didn't answer my question.
At any rate here are both answers:
If you want to change how QIcon is changing an image for a disabled mode, you will have to subclass QIcon.
If your question is about how to manipulate an image - have a look at QImage.
If none of the above answers your question, please invest more in explaining what you need.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
Yes, i want it. But i can't understand how i can solve it using subclass of QIcon.
I try:
and result:Qt Code:
To copy to clipboard, switch view to plain text mode
painterAverage.png
but i need
MaximumAverage.jpg
Sorry, you can show me simple example how using subclass of QIcon solve it?
Do you intend to call this extended functionality yourself or do you expect to somehow teach Qt to draw your custom icon in a standard situation? In other words, how do you want to use your custom "MyDisable" mode?
Drawing my custom icon in a standard situation? Do you mean:
For example, i have 30 differents "ON" icons which looks like MaximumActive.pngQt Code:
for (int i = 0; i < NumModes; ++i){ if (i == 0) { } else if (i == 1) { } else if (i == 2) { } else if(i == 3){ } pixmapLabels[i]->setPixmap(pixmap); pixmapLabels[i]->setEnabled(true); }To copy to clipboard, switch view to plain text mode
In this way i must create 30 differents "OFF" icons which looks like MaximumAverage.jpg? It's not good.
I intend to increase saturation of current icon (Active mode) and other icons (in MyDisable mode) must be with low saturation like MaximumAverage.jpg but not gray like this:
screen.jpg
Thank you.
So what you want is not a new mode but different look of icons in some of the modes that are already there, right?
If you were to implement a new mode (ok, let's say this clear -- you can't add modes to QIcon), you would have to provide some piece of code that transforms one pixmap (e.g. icon in active mode) into another (e.g. icon in disabled mode). So if you have such code then simply run it for your 30 icons and use QIcon::addPixmap() to set them to be used for one of available modes.
I do not have code that transforms one pixmap (e.g. icon in active mode) into another (e.g. icon in disabled mode). How to transform icons? Using QImage? But how decrease saturation of image using QImage?
Sometimes I regret that there is no such class
This code decrease saturation for each pixel:
What do you think, It is not too time-consuming process?Qt Code:
QImage img; img = pixmap.toImage(); int w = img.width(); int h = img.height(); for (int y = 0; y < h; ++y) { for(int x = 0; x < w; ++x) { pixel.setHsl(pixel.hue(), 30, pixel.lightness(), pixel.alpha()); img.setPixel(x, y, pixel.rgba()); } } //return QPixmap::fromImage(img, Qt::AutoColor)To copy to clipboard, switch view to plain text mode
Bookmarks