View Full Version : color setting idiom
ugluk
21st July 2011, 08:57
As I cannot set the alpha channel in any constructor of the QColor class, I am reduced to the following color-setting idiom:
QColor color;
color.setRgba(QRgb(0x88FFFFFF));
glossyGradient.setColorAt(0, color);
color.setRgba(QRgb(0x55FFFFFF));
glossyGradient.setColorAt(.1f, color);
color.setRgba(QRgb(0x33FFFFFF));
glossyGradient.setColorAt(.5f, color);
...
This really isn't something to look at. Do there exist other possibilities?
AlexSudnik
21st July 2011, 09:09
Why not to use QColor::setAlpha ( int alpha ) or QColor::setAlphaF ( qreal alpha ) ?
SixDegrees
21st July 2011, 09:13
One of the QColor constructors takes r,g,b,a values.
ugluk
21st July 2011, 10:16
Why not to use QColor::setAlpha ( int alpha ) or QColor::setAlphaF ( qreal alpha ) ?
Because doing so would not be much different to what I am doing now.
Added after 37 minutes:
One of the QColor constructors takes r,g,b,a values.
Looks like I ought to file a Qt bug.
high_flyer
21st July 2011, 11:31
As I cannot set the alpha channel in any constructor of the QColor class
As SixDegrees already stated, your assertion is false!
See this constructor:
http://doc.qt.nokia.com/latest/qcolor.html#QColor-2
Looks like I ought to file a Qt bug.
Why a bug?
A bug is when something is not working as it should.
Even if you were correct with your statement, and you could not set the alpha channel in a QColor ctror, it would still not be a bug, at worst, a missing feature.
SixDegrees
21st July 2011, 13:41
Why file a bug report? You claimed there wasn't a constructor that took an alpha channel argument; you were wrong, there is one, and it's clearly documented by Qt. How is this in any way a bug?
ugluk
26th July 2011, 20:19
Because the bugzilla accepts "bugs", which in reality are suggestions; Qt 5 is on the way, maybe something can change. Still, one might say, even though this is documented, that taking a QRgb argument and then ignoring the alpha channel in it is a bug (yes, I know it is not, but I wasted some time because of this behavior).
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.