So here is the jist of the example code
p.convertFromImage( img );
if ( !p.mask() )
if ( img.hasAlphaBuffer() ) {
bm = img.createAlphaMask();
p.setMask( bm );
} else {
bm = img.createHeuristicMask();
p.setMask( bm );
}
MoveMe w(0,0,Qt::WStyle_Customize|Qt::WStyle_NoBorder);
w.setBackgroundPixmap( p );
QString fn="tux.png";
QImage img( fn );
QPixmap p;
p.convertFromImage( img );
if ( !p.mask() )
if ( img.hasAlphaBuffer() ) {
QBitmap bm;
bm = img.createAlphaMask();
p.setMask( bm );
} else {
QBitmap bm;
bm = img.createHeuristicMask();
p.setMask( bm );
}
MoveMe w(0,0,Qt::WStyle_Customize|Qt::WStyle_NoBorder);
w.setBackgroundPixmap( p );
To copy to clipboard, switch view to plain text mode
And here is my updated 4.2 version:
QString sImageFile
= "C:/Documents and Settings/bpetty/My Documents/My Pictures/face.JPG";
BGPixmap.fromImage(BGImage); // Create Image
if (!BGPixmap.mask())
{
if (BGImage.hasAlphaChannel())
{
BGImage = BGImage.createAlphaMask();
} else {
BGImage = BGImage.createHeuristicMask();
}
BGBitmap.fromImage(BGImage);
BGPixmap.setMask(BGBitmap);
}
BGPalette.
setBrush(this
->backgroundRole
(),
QBrush(BGPixmap
));
// Create Palette
this->setFixedSize(BGImage.width(), BGImage.height()); // Set Window Size
this->setPalette(BGPalette); // Set Background Image
QString sImageFile = "C:/Documents and Settings/bpetty/My Documents/My Pictures/face.JPG";
QImage BGImage(sImageFile);
QPixmap BGPixmap;
QPalette BGPalette;
QBitmap BGBitmap;
BGPixmap.fromImage(BGImage); // Create Image
if (!BGPixmap.mask())
{
if (BGImage.hasAlphaChannel())
{
BGImage = BGImage.createAlphaMask();
} else {
BGImage = BGImage.createHeuristicMask();
}
BGBitmap.fromImage(BGImage);
BGPixmap.setMask(BGBitmap);
}
BGPalette.setBrush(this->backgroundRole(), QBrush(BGPixmap)); // Create Palette
this->setFixedSize(BGImage.width(), BGImage.height()); // Set Window Size
this->setPalette(BGPalette); // Set Background Image
To copy to clipboard, switch view to plain text mode
My code is displaying a black box... not the image. Am I doing something wrong? Is there an easier way to set the background of a dialog widget to an image?
I am also doing this:
CINWaitSplash
(QWidget * parent
= 0, Qt
::WindowFlags f
= Qt
::SplashScreen|Qt
::WindowStaysOnTopHint);
CINWaitSplash(QWidget * parent = 0, Qt::WindowFlags f = Qt::SplashScreen|Qt::WindowStaysOnTopHint);
To copy to clipboard, switch view to plain text mode
Could any of that be effecting it?
Bookmarks