Hi Guys,

I can't seem to make my QDockWidget semi-transparent, and was wondering if it is possible? Here is my code:

Qt Code:
  1. int main(int argc, char *argv[])
  2. {
  3. QApplication app(argc, argv);
  4.  
  5. //The main window just has a label in it's center
  6. QMainWindow* mainWindow = new QMainWindow(0,0);
  7. QLabel* mainLabel = new QLabel("Main Widget Label", mainWindow);
  8. mainWindow->setCentralWidget(mainLabel);
  9.  
  10. //This dock window should appear 50% transparent. Instead it is fully opaque.
  11. QDockWidget* dockWidget = new QDockWidget("Dock Widget", mainWindow);
  12. QPushButton* pushButton = new QPushButton("Dock Widget Button", dockWidget);
  13. dockWidget->setWidget(pushButton);
  14. dockWidget->setWindowOpacity(0.5);
  15. mainWindow->addDockWidget(Qt::LeftDockWidgetArea, dockWidget);
  16.  
  17. //Just to show transparent can work, this seperate widget does show up 50% transparent.
  18. QWidget *w = new QWidget(0,0);
  19. QPushButton* floatingPushButton = new QPushButton("Floating Widget Button", w);
  20. w->setWindowOpacity(0.5);
  21.  
  22. //Show the windows.
  23. mainWindow->show();
  24. w->show();
  25.  
  26. return app.exec();
  27. }
To copy to clipboard, switch view to plain text mode 

As you can see from the screenshot below, the regular QWidget is semi-transparent but the QDockWidget is not:



Is this expected? I guess it is conceivable that QDockWidgets are drawn differently (I notice they have different window decorations). Anyone know a way around this, or what I am doing wrong?

Thanks,

David