Results 1 to 6 of 6

Thread: How to make certain areas transparent with the desktop?

  1. #1
    Join Date
    Jul 2009
    Posts
    9
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default How to make certain areas transparent with the desktop?

    Hey guys,

    so I want to make a widget transparent so that the desktop background behind the widget can be seen. How is this possible?

    I've tried some paintEvent examples that I found but I didn't get any of them to work properly. If needed the whole widget can be transparent and then I can put a mask on it for the regions that i want to be completely invisible.

    The widget is without a windowmanager, so no frame around the form. I'm looking forward to hearing from you.


    Regards,
    Sir Rogers

  2. #2
    Join Date
    May 2007
    Posts
    106
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: How to make certain areas transparent with the desktop?

    Were you able to achieve that finally? I am also facing the same issue, I am trying it with Qt::WA_TranslucentBackground

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

    laurent (11th May 2010)

  4. #3
    Join Date
    Jul 2009
    Posts
    9
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to make certain areas transparent with the desktop?

    Nope unfortunately not. It seems that QT is not supporting this feature at the moment due to lack of cross platform compatibility.

    It would be a great feature to have even if it only works on Windows and OS X.


    Regards,
    Rogers

  5. #4
    Join Date
    May 2007
    Posts
    106
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: How to make certain areas transparent with the desktop?

    May be you can try setMast(). This works well if you don't want mouse events in masked area but for my case this is not the solution.

  6. #5
    Join Date
    May 2010
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to make certain areas transparent with the desktop?

    I'm using Qt 4.6.2 on windows and I was able to make a drop shadow for my window using Qt::WA_TranslucentBackground and a ARGB png in the Designer.

    In myApp constructor I set the mask with my ARGB background I used in the designer:
    Qt Code:
    1. QPixmap _pixmap(QString::fromUtf8(":/Background_/Background_/myApp_shadow.png"));
    2. this->setMask(_pixmap.mask());
    To copy to clipboard, switch view to plain text mode 
    Here is where I start my QApplication and where I set the flag:
    Qt Code:
    1. int myApp::Start(int argc, char *argv[])
    2. {
    3. QApplication a(argc, argv);
    4. myApp* w = new myApp(NULL);
    5. w->show();
    6. w->setAttribute(Qt::WA_TranslucentBackground);
    7. return a.exec();
    8. }
    To copy to clipboard, switch view to plain text mode 

    Hope I helped you like you helped me

  7. #6
    Join Date
    May 2010
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Exclamation Re: How to make certain areas transparent with the desktop?

    I forgot to mention that the widget you want to be translucent can't be the top widget, it has to be a child of something here is a working exemple:
    Qt Code:
    1. m_widgetFrame= new QWidget(0, Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);
    2. m_widgetFrame->setGeometry(0, 0, 100, 100);
    3. m_widgetFrame->setAttribute(Qt::WA_TranslucentBackground);
    4.  
    5. m_widgetContent = new QWidget(m_widgetFrame);
    6. m_widgetContent ->setStyleSheet(QString::fromUtf8("QWidget{background-color: qlineargradient(spread:reflect, x1:0, y1:1, x2:0,y2:0,stop:0 rgba(255, 255, 255, 255),stop:1 rgba(255, 255, 255, 0));}"));
    7. m_widgetContent ->setGeometry(0,0,m_widgetFrame->width(),m_widgetFrame->height());
    8.  
    9. m_widgetFrame->show();
    To copy to clipboard, switch view to plain text mode 

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. Replies: 2
    Last Post: 19th August 2008, 09:46
  3. Make the QComboBox popup translucent or transparent ?
    By charlse in forum Qt Programming
    Replies: 5
    Last Post: 18th August 2008, 16:18
  4. Replies: 1
    Last Post: 18th August 2008, 15:10
  5. how can make the widget transparent
    By duduqq in forum Qt Programming
    Replies: 2
    Last Post: 24th June 2008, 12:24

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.