Results 1 to 6 of 6

Thread: Transparent background Style

  1. #1
    Join Date
    Jan 2006
    Posts
    122
    Thanks
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Transparent background Style

    Hi,
    I'm trying to build a new QStyle where my Background will be transparent.

    I tried this in my overridden polish(QPalette &palette)
    palette.setBrush(QPalette::Window, Qt::transparent);

    But I get a black background,
    is there a different way to achieve transparency?

    Thanks
    Bye

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Transparent background Style

    Use QWidget::setWindowOpacity() for top level widgets (requires a composite manager on X11). Child widgets are transparent by default in Qt 4.1.
    J-P Nurmi

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

    Lele (17th July 2006)

  4. #3
    Join Date
    Jan 2006
    Posts
    122
    Thanks
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Transparent background Style

    Hi, thanks for answering
    well, after some more research I found this http://lists.trolltech.com/qt-intere...ad01463-0.html

    which is exactly my problem, actually I'd like only some parts of my style will be transparent, not the entire window, and as stated in http://doc.trolltech.com/qq/qq16-background.html

    "Qt 3.3 introduced a new widget property called windowOpacity for making top-level widgets (windows) transparent. This property can't be used to make child widgets semi-transparent, and it only works on window systems that support this feature (Mac OS X and Windows 2000 or later). In addition, the windowOpacity property applies to the widget as a whole, not to individual shapes or pixels."

    So if I want a mainwindow(top level widget) with just the background transparent there's no way to achieve it?

    thanks again

  5. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Transparent background Style

    I'm not 100% sure but yes, I believe there is no way to make only parts of a top level window transparent. Qt doesn't draw the top level window, it comes from the underlying system. Qt can only provide some hints to the platform what kind of window should it be (like transparent).
    J-P Nurmi

  6. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Transparent background Style

    Quote Originally Posted by Lele
    I'd like only some parts of my style will be transparent, not the entire window
    How about QWidget::setMask()?

  7. #6
    Join Date
    Jan 2006
    Posts
    122
    Thanks
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Transparent background Style

    thanks,
    well in my case I'd need all Background as tansparent, so not really a region but all the area
    where the other widgets are attached.

Similar Threads

  1. Replies: 3
    Last Post: 8th December 2006, 18:51
  2. QFrame and its background
    By high_flyer in forum Qt Programming
    Replies: 2
    Last Post: 23rd June 2006, 20:32
  3. QLabel background color
    By munna in forum Newbie
    Replies: 3
    Last Post: 1st May 2006, 15:36
  4. background colour
    By kw in forum Qt Programming
    Replies: 6
    Last Post: 11th April 2006, 00:44
  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.