HI all,
i have a requirement to display a transparent window such that when it is displayed i should be able to see my Desktop.

I have used setWindowOpacity() for this but it dosen't work.
Plz give me suggestion to correct my program.
Below is a small piece of code..................

Qt Code:
  1. TransparentWindow::TransparentWindow(QWidget *parent)
  2. : QDialog(parent, Qt::FramelessWindowHint)
  3. {
  4.  
  5. QPushButton *bttn = new QPushButton("Test",this);
  6. bttn->setGeometry( QRect( 150, 100,200, 25 ) );
  7. connect(bttn, SIGNAL(clicked()), this, SLOT(setOpaque()));
  8.  
  9. setWindowTitle(tr("Transparent Window"));
  10. //setFixedHeight(sizeHint().height());
  11.  
  12.  
  13. }
  14. void TransparentWindow::paintEvent(QPaintEvent *)
  15. {
  16. QPainter painter(this);
  17. QLinearGradient grad(0, 0, rect().width(), rect().height());
  18.  
  19. painter.fillRect(0, 0, rect().width(), rect().height(), grad);
  20.  
  21. }
  22.  
  23. void TransparentWindow::setOpaque()
  24. {
  25. setAttribute(Qt::WA_NoSystemBackground, true);
  26. setAttribute(Qt::WA_TranslucentBackground, true);
  27. setWindowOpacity(0.1);
  28. repaint();
  29.  
  30. }
To copy to clipboard, switch view to plain text mode 

Regards

Raghav