[Qt-interest] QPixmap and alpha-channel
Oliver.Knoll at comit.ch
Oliver.Knoll at comit.ch
Tue Dec 16 15:03:35 CET 2008
Khizer Kapadia wrote on Monday, December 15, 2008 8:29 PM:
> Hi,
> First off, I would like declare that I am developing apps for a
> platform which has qt 2.3 in it (yeah I know its ancient). And I am
> new with Qt :)
At least you are confronted with fewer classes than when learning with Qt 4.x ;)
> What I am trying to achieve is to draw a semi-transparent pushbutton.
> I have various threads but haven't found a conclusive answer.
Qt 2.x is indeed years back, but AFAIK Qt 2.x does not support alpha blending (I might be wrong though)! So the alpha channel is mapped to 0 (transparent) where alpha <= 127 and 255 (opaque) else - or so.
The only way to make pixels selectively invisible is to set a separate *mask* which defines the pixels to be in-/visible. But that's it, no semi-transparency (aka alpha blending):
http://doc.trolltech.com/2.3/qpixmap.html#68a75d
Qt 2.x offers you a heuristic "auto-mask" method, given an icon QPixmap:
http://doc.trolltech.com/2.3/qpixmap.html#20dfb1
Or preferrably from a QImage (faster!):
http://doc.trolltech.com/2.3/qimage.html#582c18
Cheers, Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22
More information about the Qt-interest-old
mailing list