Results 1 to 6 of 6

Thread: QWidget setMask fully transparent.

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

    Default QWidget setMask fully transparent.

    Hey guys,

    I want to apply a fully transparent mask to a QWidget.

    I tried the following:

    Qt Code:
    1. setMask(QRect(0, 0, 0, 0)); // Doesn't work
    To copy to clipboard, switch view to plain text mode 

    and this:

    Qt Code:
    1. setMask(QRect(-1, -1, 1, 1)); // Does work
    To copy to clipboard, switch view to plain text mode 

    How am I supposed to set a fully transparent mask to a widget ?

    Thanks.

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QWidget setMask fully transparent.

    Use either full transparent .png image. Or use Qt::transparent. See the docs, this is very easy.
    I think full transparent mask is of no use.
    Use:
    Qt Code:
    1. QWidget::setWindowOpacity ( qreal level );
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: QWidget setMask fully transparent.

    Hi,

    I need that behavior on a classic QWidget not a window.

  4. #4
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QWidget setMask fully transparent.

    Quote Originally Posted by bunjee View Post
    I need that behavior on a classic QWidget not a window.
    Yes, that was for QWidget only.

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

    Default Re: QWidget setMask fully transparent.

    Qt Code:
    1. Masked widgets receive mouse events only on their visible portions.
    To copy to clipboard, switch view to plain text mode 

    The setWindowOpacity is not a suitable solution because I need that behavior.

    Thanks anyway.

  6. #6
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QWidget setMask fully transparent.

    Quote Originally Posted by bunjee View Post
    The setWindowOpacity is not a suitable solution because I need that behavior.
    Then go ahead with setMask.

Similar Threads

  1. QGraphicsView and adding QWidget with transparent areas
    By sting73 in forum Qt Programming
    Replies: 2
    Last Post: 28th April 2009, 11:19
  2. Transparent Qwidget
    By naruto_9w in forum Qt Programming
    Replies: 10
    Last Post: 14th February 2009, 00:42
  3. Qt transparent Widget
    By Vipin Vijayan in forum Qt Programming
    Replies: 2
    Last Post: 27th January 2009, 12:33
  4. Replies: 0
    Last Post: 11th November 2008, 15:36
  5. Transparent QWidget on QGLWidget
    By showhand in forum Qt Programming
    Replies: 2
    Last Post: 27th November 2006, 01:00

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.