When setting a pixmap with an alpha on a widget, how can I remove the widget's gray edges that shine through?
Answer:
In order to remove the non-transparent edges from the widget, you can set a heuristic mask on the pixmap. This will cause the outer most color to be removed where it is used in the pixmap. Then you can set the QBitmap which is returned from the call to createHeuristicMask() as a mask on your widget. This will cause only the pixels of the widget for which bitmap has a corresponding 1 bit to be visible. Now you can set your pixmap on the widget, and only the pixels that correspond to where the mask has a bit set will be visible. See the documentation:
http://doc.trolltech.com/4.2/qwidget.html#setMask
http://doc.trolltech.com/4.2/qpixmap.html#createHeuristicMask
See the following example for a demonstration:
#include <QtGui>
int main(int argc, char **argv)
{
Application app(argc, argv);
QPixmap pixmap("pix_with_alpha");
QBitmap bm(pixmap.createHeuristicMask());
QSplashScreen splash(0);
splash.setMask(bm);
splash.setPixmap(pixmap);
splash.show();
return app.exec();
}