[Qt-interest] QIcon behaves differently in Linux and Windows

Marcelo Magno T. Sales mmtsales at gmail.com
Mon Jan 31 00:54:43 CET 2011


Hello,

The code:

btnPicture->setEnabled(false);
QIcon icon;
icon.addPixmap(image, QIcon::Disabled);
btnPicture->setIcon(icon);

produces different results in Linux and Windows. btnPicture is a 
QPushButton * and image is a QPixmap containing a colored image.
When running this on Windows, btnPicture shows a colored icon as I would 
expect. However, when running on Linux, btnPicture shows an icon in 
shades of gray (?!) The QPushButton is disabled, but I have added the 
QPixmap to the QIcon specifying explicitly that the image should be used 
in the QIcon::Disabled mode and not in the QIcon::Normal mode. Is this a 
bug in QIcon or is there something subtle here I'm not seeing?

Thanks,

Marcelo



More information about the Qt-interest-old mailing list