Results 1 to 5 of 5

Thread: Transparent Window Background QtConfig settings?

  1. #1
    Join Date
    Oct 2012
    Posts
    8
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Transparent Window Background QtConfig settings?

    I found this code example on http://www.codeprogress.com/cpp/libr...ntBg&index=191

    It's supposed to create a QT window and have it be transparent so that the desktop will show through it.

    When I run the code, the background simply shows up as black instead of transparent.

    The webpage notes that if the QT GUI styling does not work as expected, check your qtconfig settings. But I'm not sure which settings I'm supposed to modify.

    Has anyone run into this before?

    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char *argv[])
    4. {
    5. QApplication app(argc, argv);
    6.  
    7. QMainWindow *window = new QMainWindow();
    8. window->setAttribute( Qt::WA_TranslucentBackground );
    9. window->setWindowTitle(QString::fromUtf8("QMainWindow Transparent Background"));
    10. window->resize(800, 250);
    11.  
    12. QLCDNumber *number = new QLCDNumber();
    13. number->setFixedSize(800, 245);
    14. number->setDigitCount(12);
    15. number->display(QTime::currentTime().toString(QString("hh:mm:ss.zzz")));
    16.  
    17.  
    18. window->setCentralWidget(number);
    19. window->show();
    20.  
    21. return app.exec();
    22. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Sep 2012
    Location
    Iran, Tehran
    Posts
    76
    Thanks
    17
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Transparent Window Background QtConfig settings?

    if you are using Windows, add this line after line 8

    Qt Code:
    1. window->setWindowFlags(Qt::FramelessWindowHint);
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Oct 2012
    Posts
    8
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Transparent Window Background QtConfig settings?

    I'm using ubuntu. I have tried what you suggested, and it did not resolve my issue. Any other ideas?

  4. #4
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Transparent Window Background QtConfig settings?

    check which manager is running in ur ubuntu ..
    * Metacity
    use gconf-editor->apps->metacity->enablecompositing_manager.
    *compiz
    use compiz-manager and increase the transparency .

    u can check it in ur linux process list .. ps -ax
    "Behind every great fortune lies a crime" - Balzac

  5. #5
    Join Date
    Oct 2012
    Posts
    8
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Transparent Window Background QtConfig settings?

    Thank you wagmare! That solved my problem! I had to enable compositing on metacity

    https://help.ubuntu.com/community/Metacity

Similar Threads

  1. Replies: 0
    Last Post: 5th April 2011, 13:36
  2. transparent background
    By fruzzo in forum Qt Programming
    Replies: 13
    Last Post: 18th March 2008, 14:42
  3. Transparent background on QLabel on transparent QWidget
    By codeslicer in forum Qt Programming
    Replies: 1
    Last Post: 13th February 2008, 02:10
  4. QDialog w/ transparent background
    By LarryDobson in forum Qt Programming
    Replies: 6
    Last Post: 26th September 2006, 19:26
  5. Why the background is not transparent?
    By SkripT in forum Qt Programming
    Replies: 4
    Last Post: 9th May 2006, 01:17

Tags for this Thread

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.