Results 1 to 4 of 4

Thread: Splash screen application like with transparent background ... how to ?

  1. #1
    Join Date
    Jan 2006
    Posts
    162
    Thanks
    9
    Qt products
    Qt3
    Platforms
    Windows

    Default Splash screen application like with transparent background ... how to ?

    Hi,

    I have an application with a pixmap as background (it is not an application with a palette background pixmap, just an application that has a pixmap used as background). The pixmap is a png one with some transparency.

    What I want to do is display my application like a splash screen (no title, no status bar) with its background (the pixmap) transparent (only the transparent part of the png bitmap).

    I am able to display my application as a splash screen (I use some flags for it), the transparent part of the pixmap is transparent but I still see the application background color.

    I don't know how to do it, could someone help me ?

    Thanks in advance

  2. #2
    Join Date
    Feb 2006
    Location
    Enschede, NL, EU
    Posts
    19
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Splash screen application like with transparent background ... how to ?

    I used teh google to look for examples of creating non-rectangular windows.. which it seems you want to do:

    http://www.ida.liu.se/~TDDB28/kursbi...t/examples/tux

    Good luck with it...

  3. #3
    Join Date
    Aug 2006
    Posts
    90
    Thanks
    6
    Thanked 4 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Splash screen application like with transparent background ... how to ?

    So here is the jist of the example code
    Qt Code:
    1. QString fn="tux.png";
    2.  
    3. QImage img( fn );
    4. p.convertFromImage( img );
    5. if ( !p.mask() )
    6. if ( img.hasAlphaBuffer() ) {
    7. QBitmap bm;
    8. bm = img.createAlphaMask();
    9. p.setMask( bm );
    10. } else {
    11. QBitmap bm;
    12. bm = img.createHeuristicMask();
    13. p.setMask( bm );
    14. }
    15. MoveMe w(0,0,Qt::WStyle_Customize|Qt::WStyle_NoBorder);
    16. w.setBackgroundPixmap( p );
    To copy to clipboard, switch view to plain text mode 

    And here is my updated 4.2 version:
    Qt Code:
    1. QString sImageFile = "C:/Documents and Settings/bpetty/My Documents/My Pictures/face.JPG";
    2.  
    3. QImage BGImage(sImageFile);
    4. QPixmap BGPixmap;
    5. QPalette BGPalette;
    6. QBitmap BGBitmap;
    7.  
    8. BGPixmap.fromImage(BGImage); // Create Image
    9. if (!BGPixmap.mask())
    10. {
    11. if (BGImage.hasAlphaChannel())
    12. {
    13. BGImage = BGImage.createAlphaMask();
    14. } else {
    15. BGImage = BGImage.createHeuristicMask();
    16. }
    17.  
    18. BGBitmap.fromImage(BGImage);
    19. BGPixmap.setMask(BGBitmap);
    20. }
    21.  
    22. BGPalette.setBrush(this->backgroundRole(), QBrush(BGPixmap)); // Create Palette
    23.  
    24. this->setFixedSize(BGImage.width(), BGImage.height()); // Set Window Size
    25.  
    26. 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:
    Qt Code:
    1. 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?

  4. #4
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Splash screen application like with transparent background ... how to ?

    You can't directly create transparent windows with Qt (at least, not yet). Your underlying windowing system may be able to do it however, so check there.

    But what you can do is to create shaped windows. This is a different concept than transparency, but may be the effect you want. See the Qt example program "shapedclock" for more information.

Similar Threads

  1. How to set Qt window transparent?
    By montylee in forum Qt Programming
    Replies: 17
    Last Post: 24th December 2013, 20:11
  2. Frame buffer background during splash screen
    By Micawber in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 23rd January 2009, 19:38
  3. Replies: 7
    Last Post: 4th October 2008, 12:14
  4. Using QGraphicsView as a Splash Screen (repaint issues)
    By chezifresh in forum Qt Programming
    Replies: 3
    Last Post: 4th June 2008, 21:22
  5. Replies: 1
    Last Post: 5th April 2006, 16:44

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.