I implemented a QDialog with transparent background, but i move the mouse over QDialog, background becomes dark.

What's the problem?


my code:

Note: numPadDialog is derived class of QDialog.

Qt Code:
  1. // Constructor, call some functions to implent QDialog
  2. numPadDialog::numPadDialog() {
  3. // TODO Auto-generated constructor stub
  4. setWallpaper(); //This function try put a background dark semi-transparent
  5. setNumericPad(); // This function put the image of numpad
  6. configureInterfaceNumericPad(); // This function configure map of the buttons of numpad
  7. setInfo("Configure this parameter: "); //This function put extra information about numPad
  8. showDialog(); // This function show the QDialog
  9. }
  10.  
  11. //This function try put a background dark semi-transparent
  12. void numPadDialog::setWallpaper(){
  13.  
  14. mask= new QLabel(this);
  15. //set image
  16. QString style;
  17. style.clear();
  18. QString numPadPath;
  19. numPadPath.clear();
  20. numPadPath.append(QDir::currentPath());
  21. numPadPath.append(WALLPAPER_DIRECTORY);
  22. numPadPath.append(KEYPAD_BACKGROUND); // image semi-transparent, dark
  23.  
  24. style.append("background-color: transparent; background: transparent; background-image: url(");
  25. style.append(numPadPath);
  26. style.append("); ");
  27. mask->setStyleSheet(style);
  28. mask->setGeometry(0,0,320,240);
  29. mask->setFocusPolicy(Qt::NoFocus);
  30. }
  31.  
  32.  
  33. // This function put the image of numpad
  34. void numPadDialog::setNumericPad(){
  35.  
  36. numPad= new QLabel(this);
  37. //set image
  38. QString style;
  39. style.clear();
  40. QString numPadPath;
  41. numPadPath.clear();
  42. numPadPath.append(QDir::currentPath());
  43. numPadPath.append(WALLPAPER_DIRECTORY);
  44. numPadPath.append(KEYPAD_NUMPAD);
  45.  
  46. style.append("background-color: transparent; background: transparent; background-image: url(");
  47. style.append(numPadPath);
  48. style.append("); ");
  49. numPad->setStyleSheet(style);
  50. numPad->setGeometry(0,0,320,240);
  51. numPad->setFocusPolicy(Qt::NoFocus);
  52. }
  53.  
  54. // This function show the QDialog
  55. void numPadDialog::showDialog(){
  56. this->setWindowFlags(Qt::FramelessWindowHint);
  57. this->setAttribute(Qt::WA_NoSystemBackground);
  58. //this->setAttribute(Qt::WA_TransparentForMouseEvents);
  59. //this->setAttribute(Qt::WA_NoBackground);
  60. this->setFixedSize(320,240); // ( x , y )
  61. this->setFocusPolicy(Qt::NoFocus);
  62. exec();
  63. }
To copy to clipboard, switch view to plain text mode