Results 1 to 3 of 3

Thread: Transparent area inside semi transparent area.

  1. #1
    Join Date
    Feb 2015
    Posts
    2
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Transparent area inside semi transparent area.

    Hi Community,

    I'm new to Qt and already have a pretty decent task to solve.

    I want to implement screen capture functionality. To capture a part of the screen the user can enter selection mode.
    In selection mode, I want to show a semi-transparent layer expanding over all screens and a fully transparent rectangular layer inside which can be resized and moved.
    The later one indicates the selected area. All windows on the desktop should visually appear below these two layers. That is they are semi-transparent if not inside the selection area. However interaction with those windows should be possible, that is they can e.g. be moved and resized.

    How can I archive that behavior? Any help/code snippets are highly appreciated.

    I'm using the latest Qt version under Windows.

  2. #2
    Join Date
    Feb 2015
    Posts
    2
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Transparent area inside semi transparent area.

    Can anyone point me in the right direction, please.

    I know how to create a fullscreen semi-transparent window on top.
    How can I place a moveable resizable widget with full transparency inside it?
    How can I still access the application windows below them?

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Transparent area inside semi transparent area.

    One way to have a "hole" in a window is to paint its content using a QPainterPath which has two rectangles: the one for the full size and the hole.
    Using a semi transparent color to fill that path will only apply that color to the intersection of the two rectangles.

    Something like this
    Qt Code:
    1. void MyWidget::paintEvent(QPaintEvent *)
    2. {
    3. QPainter painter(this);
    4.  
    5. path.addRect(rect());
    6. path.addRect(m_holeRect);
    7. painter.fillPath(path, semiTransparentColor);
    8. }
    To copy to clipboard, switch view to plain text mode 

    As for interacting with windows below your window, that is out of scope for the application. You'll need to consult operating system documentation for that whether it is possible at all and if so, how to do that.

    Cheers,
    _

Similar Threads

  1. How to get an area of the widget transparent...???
    By kapoorsudhish in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 5th March 2010, 04:20
  2. Replies: 1
    Last Post: 22nd January 2010, 14:45
  3. QWidget inside QGroupbox semi transparent [Qt 4.3.1]
    By desch in forum Qt Programming
    Replies: 7
    Last Post: 26th February 2009, 10:00
  4. Non-transparent QWidget on semi-transparent parent
    By EuroElessar in forum Qt Programming
    Replies: 0
    Last Post: 29th August 2008, 16:20
  5. leaveEvent on transparent area issue
    By nooky59 in forum Qt Programming
    Replies: 10
    Last Post: 8th January 2008, 13:22

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.