Results 1 to 2 of 2

Thread: Partial window transparency

  1. #1
    Join Date
    Jan 2007
    Location
    Paris
    Posts
    459
    Thanks
    98
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5

    Default Partial window transparency

    Hey folks,

    Is it possible for a main QWidget or a QMainWidget to be partially transparent in Qt 4.5 ?

  2. #2
    Join Date
    Mar 2009
    Posts
    3
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Cool Re: Partial window transparency

    Of course it is! Just set this flag (introduced in 4.5, it was trickier before):

    topLevelWidget->setAttribute( Qt::WA_TranslucentBackground, true );

    and if you can't see behind your window, just use some non-opaque color, like:

    QPalette pal;
    pal.setBrush( QPalette::Window, QColor(255, 0, 0, 64) );
    topLevelWidget->setPalette(pal);
    topLevelWidget->setAutoFillBackground(true); // maybe it's the default!

    and if you still have troubles, *paint with a glass painting* on your paintEvent(...) ;-), like:

    QPainter p( this );
    p.fillRect( rect(), Qt::transparent /*QColor(0, 0, 0, 0)*/ );

    Note that on X11 your window will be transparent only with compositing active (compiz, kwin4 with effects, ...etc).

  3. The following user says thank you to koral for this useful post:

    bunjee (5th June 2009)

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. QMain Window Problem
    By maveric in forum Qt Programming
    Replies: 1
    Last Post: 24th May 2008, 15:51
  3. Set a window as child at runtime
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 26th November 2007, 09:30
  4. Change shape of window / animate window
    By sabeesh in forum Qt Programming
    Replies: 3
    Last Post: 31st October 2007, 08:16
  5. move parent window to the front.
    By hvengel in forum Qt Programming
    Replies: 4
    Last Post: 2nd February 2007, 08:41

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.