Showing a splash screen with transparency.
Hello,
In my app, I've got such a piece of code:
Code:
splashScreen.show();
splashScreen.
showMessage(QString("Loading..."),Qt
::AlignCenter | Qt
::AlignBottom,
QColor(0,
150,
255));
MainWindow w;
splashScreen.finish(&w);
w.show();
It shows me a splash screen, but in places that should be transparent (as the base for this splash screen is a PNG image) there is background. Is this possible to have a splash screen with transparency?
Re: Showing a splash screen with transparency.
Did you try to set opacity property to your splash window?
Re: Showing a splash screen with transparency.
But I want only the transparent placec from PNG to be transparent and this doesn't seem to help me with that.
Re: Showing a splash screen with transparency.
Re: Showing a splash screen with transparency.
I have next piece of code in my project and it produces transparent background for png-image I use.
Code:
QPixmap pixmap
(":/images/splash.png");
splash.setMask(pixmap.mask());
splash.show();
Re: Showing a splash screen with transparency.
Thank you very much for your responses. Unfortunately, Qt::WA_TranslucentBackground (together with Qt::FramelessWindowHint flag passed to the splash screen constructor) didn't work - it made the splash screen completely transparent - not only its "transparent places" from PNG. Tsp, your solution works well :).
Re: Showing a splash screen with transparency.
hello i tried this but no joy.
Code:
#include <QtGui/QApplication>
#include<QTimer>
#include <QSplashScreen>
#include <QMainWindow>
int main(int argc, char *argv[])
{
//splash.setMask(pixmap.mask());
splash.
showMessage(QString("Loading..."),Qt
::AlignCenter | Qt
::AlignBottom,
QColor(0,
150,
255));
splash.show();
QTimer::singleShot(1500,
&splash,
SLOT(close
()));
QTimer::singleShot(1500,
&mainWin,
SLOT(show
()));
return a.exec();
}
only the main window is displayed after timeout. the image splash.png is in my working directory.
if i uncomment splash.setMask(pixmap.mask()); i get: invalid use of incomplete type 'struct QBitmap' forward declaration of 'struct QBitmap'.
any hints? thanks
Re: Showing a splash screen with transparency.
Quote:
Originally Posted by
raedbenz
if i uncomment splash.setMask(pixmap.mask()); i get: invalid use of incomplete type 'struct QBitmap' forward declaration of 'struct QBitmap'.
You must include QBitmap header.
Re: Showing a splash screen with transparency.
Quote:
Originally Posted by
saa7_go
You must include QBitmap header.
thanks. but still no splash screen is displayed.
Re: Showing a splash screen with transparency.
Quote:
Originally Posted by
raedbenz
image splash.png is in my working directory
Maybe the problem is in the way you are are referring to splash screen file i.e.
You are using :/ prefix, so the file should be defined in the resource file, maybe you have not done that?
Re: Showing a splash screen with transparency.
Quote:
Originally Posted by
tsp
Maybe the problem is in the way you are are referring to splash screen file i.e.
You are using
:/ prefix, so the file should be defined in the
resource file, maybe you have not done that?
Hello,
i have added this, res.qrc
Code:
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>twirl.png</file>
<file>splash.png</file>
</qresource>
</RCC>
and when i compile i get :: error: [debug/qrc_res.cpp] Error 1
my project file is:
Code:
SOURCES += \
main2.cpp
RESOURCES += \
res.qrc
thanks
Re: Showing a splash screen with transparency.
Quote:
Originally Posted by
tsp
I have next piece of code in my project and it produces transparent background for png-image I use.
Code:
QPixmap pixmap
(":/images/splash.png");
splash.setMask(pixmap.mask());
splash.show();
Thanks.. It works :)