Results 1 to 12 of 12

Thread: Showing a splash screen with transparency.

  1. #1
    Join Date
    Feb 2010
    Posts
    68
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Showing a splash screen with transparency.

    Hello,

    In my app, I've got such a piece of code:
    Qt Code:
    1. QSplashScreen splashScreen(QPixmap(":/data/other/splashScreen.png"));
    2. splashScreen.show();
    3. splashScreen.showMessage(QString("Loading..."),Qt::AlignCenter | Qt::AlignBottom,QColor(0,150,255));
    4.  
    5. MainWindow w;
    6. splashScreen.finish(&w);
    7. w.show();
    To copy to clipboard, switch view to plain text mode 

    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?

  2. #2
    Join Date
    Apr 2010
    Location
    Rostov-na-Donu, Russia
    Posts
    153
    Thanks
    2
    Thanked 26 Times in 23 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Showing a splash screen with transparency.

    Did you try to set opacity property to your splash window?

  3. #3
    Join Date
    Feb 2010
    Posts
    68
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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.

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Showing a splash screen with transparency.

    Try to play with Qt::WA_TranslucentBackground

  5. #5
    Join Date
    Sep 2009
    Location
    Finland
    Posts
    63
    Thanks
    1
    Thanked 22 Times in 19 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default 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.

    Qt Code:
    1. QPixmap pixmap(":/images/splash.png");
    2. QSplashScreen splash(pixmap);
    3. splash.setMask(pixmap.mask());
    4. splash.show();
    To copy to clipboard, switch view to plain text mode 

  6. The following 3 users say thank you to tsp for this useful post:

    Bong.Da.City (12th September 2010), kremuwa (23rd July 2010), saa7_go (22nd July 2010)

  7. #6
    Join Date
    Feb 2010
    Posts
    68
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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 .

  8. #7
    Join Date
    Apr 2010
    Posts
    23
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Showing a splash screen with transparency.

    hello i tried this but no joy.
    Qt Code:
    1. #include <QtGui/QApplication>
    2.  
    3. #include<QTimer>
    4. #include <QSplashScreen>
    5. #include <QMainWindow>
    6.  
    7. int main(int argc, char *argv[])
    8. {
    9.  
    10. QApplication a(argc, argv);
    11.  
    12. QPixmap pixmap(":/splash.png");
    13. QSplashScreen splash(pixmap);
    14. //splash.setMask(pixmap.mask());
    15.  
    16. splash.showMessage(QString("Loading..."),Qt::AlignCenter | Qt::AlignBottom,QColor(0,150,255));
    17. splash.show();
    18.  
    19.  
    20. QMainWindow mainWin;
    21.  
    22. QTimer::singleShot(1500, &splash, SLOT(close()));
    23.  
    24. QTimer::singleShot(1500, &mainWin, SLOT(show()));
    25.  
    26. return a.exec();
    27.  
    28. }
    To copy to clipboard, switch view to plain text mode 
    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

  9. #8
    Join Date
    Jun 2010
    Location
    Salatiga, Indonesia
    Posts
    160
    Thanks
    11
    Thanked 32 Times in 29 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    1

    Default Re: Showing a splash screen with transparency.

    Quote Originally Posted by raedbenz View Post
    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.

    Qt Code:
    1. #include <QBitmap>
    To copy to clipboard, switch view to plain text mode 

  10. #9
    Join Date
    Apr 2010
    Posts
    23
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Showing a splash screen with transparency.

    Quote Originally Posted by saa7_go View Post
    You must include QBitmap header.

    Qt Code:
    1. #include <QBitmap>
    To copy to clipboard, switch view to plain text mode 
    thanks. but still no splash screen is displayed.

  11. #10
    Join Date
    Sep 2009
    Location
    Finland
    Posts
    63
    Thanks
    1
    Thanked 22 Times in 19 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Showing a splash screen with transparency.

    Quote Originally Posted by raedbenz View Post
    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.

    Qt Code:
    1. QPixmap pixmap(":/splash.png");
    To copy to clipboard, switch view to plain text mode 
    You are using :/ prefix, so the file should be defined in the resource file, maybe you have not done that?

  12. #11
    Join Date
    Apr 2010
    Posts
    23
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Showing a splash screen with transparency.

    Quote Originally Posted by tsp View Post
    Maybe the problem is in the way you are are referring to splash screen file i.e.

    Qt Code:
    1. QPixmap pixmap(":/splash.png");
    To copy to clipboard, switch view to plain text mode 
    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
    Qt Code:
    1. <!DOCTYPE RCC><RCC version="1.0">
    2. <qresource>
    3. <file>twirl.png</file>
    4. <file>splash.png</file>
    5. </qresource>
    6. </RCC>
    To copy to clipboard, switch view to plain text mode 
    and when i compile i get :: error: [debug/qrc_res.cpp] Error 1

    my project file is:
    Qt Code:
    1. SOURCES += \
    2. main2.cpp
    3.  
    4. RESOURCES += \
    5. res.qrc
    To copy to clipboard, switch view to plain text mode 
    thanks

  13. #12
    Join Date
    Aug 2010
    Posts
    107
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Showing a splash screen with transparency.

    Quote Originally Posted by tsp View Post
    I have next piece of code in my project and it produces transparent background for png-image I use.

    Qt Code:
    1. QPixmap pixmap(":/images/splash.png");
    2. QSplashScreen splash(pixmap);
    3. splash.setMask(pixmap.mask());
    4. splash.show();
    To copy to clipboard, switch view to plain text mode 
    Thanks.. It works

Similar Threads

  1. Problem with Splash Screen ?
    By vinod in forum Qt Programming
    Replies: 13
    Last Post: 11th April 2020, 17:15
  2. How to Keep Splash Screen and App on Same Display
    By ajb_advance in forum Qt Programming
    Replies: 2
    Last Post: 4th March 2009, 11:49
  3. Splash screen showing for two seconds
    By Koas in forum Qt Programming
    Replies: 5
    Last Post: 17th October 2008, 19:40
  4. Splash Screen
    By Salazaar in forum Newbie
    Replies: 27
    Last Post: 4th June 2007, 17:31
  5. QTimer based Splash Screen
    By bpetty in forum Newbie
    Replies: 6
    Last Post: 15th December 2006, 00:51

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.