Results 1 to 6 of 6

Thread: Erasing on transparent widget

  1. #1
    Join Date
    Mar 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Erasing on transparent widget

    I have a widget with a transparent background.

    setAttribute(Qt::WA_OpaquePaintEvent,true);
    setPalette(QPalette(Qt::transparent));

    I draw some stuff on the widget

    QPainter p(this);
    p.fillRect(0,0,10,10,Qt::black);

    I would now like to erase the rectangle so that the area is once again transparent and the widgets underneath show through. I can't seem to figure out out to do this.

    p.fillRect(0,0,10,10,Qt::transparent); doesn't work.

    Any ideas?

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Erasing on transparent widget

    I am not sure how it is with transparent color, but have you tried to play around with QPainter::setCompositionMode()?

  3. #3
    Join Date
    Mar 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Erasing on transparent widget

    Hi Lykurg, thanks for the reply.
    I've tried every composition mode. None seem to work.

  4. #4
    Join Date
    Jan 2007
    Posts
    92
    Thanks
    14
    Thanked 1 Time in 1 Post

    Default Re: Erasing on transparent widget

    setAutoFillBackground(TRUE);

    or try:-
    setAttribute(Qt::WA_TranslucentBackground,true );

  5. #5
    Join Date
    Mar 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Erasing on transparent widget

    No luck

    Current setup:

    setAttribute(Qt::WA_OpaquePaintEvent,true);
    setAttribute(Qt::WA_TranslucentBackground,true);
    setAutoFillBackground(true);
    setPalette(Qt::transparent);

    calling p.eraseRect... doesn't seem to erase anything

  6. #6
    Join Date
    Mar 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Erasing on transparent widget

    Anyone? Please

Similar Threads

  1. Qt transparent Widget
    By Vipin Vijayan in forum Qt Programming
    Replies: 2
    Last Post: 27th January 2009, 12:33
  2. Draw New data, without erasing old ones
    By linuxdev in forum Newbie
    Replies: 11
    Last Post: 7th January 2009, 08:34
  3. Qt4.1 Transparent Widget
    By djoul in forum Qt Programming
    Replies: 14
    Last Post: 26th September 2006, 16:06
  4. Transparent TextEdit or Widget
    By showhand in forum Qt Programming
    Replies: 8
    Last Post: 26th May 2006, 05:58
  5. transparent widget
    By hijinks in forum Qt Programming
    Replies: 2
    Last Post: 20th February 2006, 09:43

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
  •  
Qt is a trademark of The Qt Company.