[Qt-interest] Transparent background QVtkWidget

Gabriel M. Beddingfield gabrbedd at gmail.com
Fri Apr 30 20:36:09 CEST 2010



On Fri, 30 Apr 2010, Guillaume DARDENNE wrote:

> I use QVtkWidget in order to display a 3D vtk scene.
> I would like to make the background of the vtkwidget transparent.
>
> I know that there is a function setWindowOpacity() for this but it doesn't
> work (I have a black background).

Not exactly sure of your context (e.g. QVtk or main 
window or whatever), but here's something that's worked 
for me:

     MyMainWindow::setup()
     {
         setWindowFlags( Qt::Window
                         | Qt::FramelessWindowHint
             );

     #if QT_VERSION >= 0x040500
         setAttributes(Qt::WA_TranslucentBackground);
     #endif

         // ...
     }

I also found that I had to use Widget::setMask() to get the 
results that I wanted.

Hope it helps!

-gabriel




More information about the Qt-interest-old mailing list