Results 1 to 9 of 9

Thread: Transparent Widgets

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2017
    Posts
    19
    Thanks
    10
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Transparent Widgets

    Hi everyone,
    I want to make a transparent window like:
    trpr.png

    I tried following codes:

    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MainWindow)
    4. {
    5. ui->setupUi(this);
    6.  
    7. setAutoFillBackground( false );
    8. setWindowFlags(Qt::FramelessWindowHint);
    9. // setAttribute(Qt::WA_TranslucentBackground);
    10. // setAttribute(Qt::WA_TransparentForMouseEvents);
    11.  
    12. QLinearGradient alphaGradient(rect().topLeft(), rect().bottomLeft());
    13. alphaGradient.setColorAt(0.0, Qt::transparent);
    14. alphaGradient.setColorAt(0.5, Qt::black);
    15. alphaGradient.setColorAt(1.0, Qt::transparent);
    16. QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect(this);
    17. effect->setOpacityMask(alphaGradient);
    18. effect->setOpacity(0.8);
    19. setGraphicsEffect(effect);
    20. }
    To copy to clipboard, switch view to plain text mode 
    If I use "WA_TranslucentBackground" background will be omitted from the widget (you can select anything behind it !) but, I need a semi transparent window which its opacity/transparency can be adjusted.
    Thanks.
    Last edited by CodeFreak; 3rd August 2018 at 18:40.

Similar Threads

  1. Replies: 2
    Last Post: 31st May 2010, 11:57
  2. Qt3 - Multiple transparent widgets
    By bythesea in forum Qt Programming
    Replies: 4
    Last Post: 11th September 2009, 11:24
  3. Mac OS X Top-Level Transparent Widgets
    By tinsuke in forum Qt Programming
    Replies: 0
    Last Post: 17th October 2008, 16:01
  4. Transparent widgets on top of QGLWidget
    By tseval in forum Qt Programming
    Replies: 1
    Last Post: 12th May 2007, 21:03
  5. Transparent widgets
    By incapacitant in forum Newbie
    Replies: 10
    Last Post: 21st March 2006, 18:01

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.