I was trying to add shadow effect in the qlabel using QGraphicsDropShadowEffect. so i added the effect like this .

Qt Code:
  1. QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect();
  2. effect->setBlurRadius(0);
  3. effect->setColor(QColor(255, 0, 0));
  4. effect->setOffset(1,1);
  5. label1->setGraphicsEffect(effect);
To copy to clipboard, switch view to plain text mode 
but the effect is looking weird as for other widget like spinbox it is working proper .

problem.png here the shadow is coming for the whole QLabel and not for the text in qlabel .

the right one is a qspinbox , it works properly for it but for qlable ,it looks odd. it behaves same as for all the labels in the parent .

but if i take the code and make a sample application it works properly ..

the sample app

Qt Code:
  1. QApplication app(argc,argv);
  2. QMainWindow* window = new QMainWindow();
  3. QWidget* centralWidget = new QWidget();
  4.  
  5. QSpinBox *spinIt = new QSpinBox;
  6. QGridLayout *gridLayout = new QGridLayout;
  7.  
  8. centralWidget->setLayout(gridLayout);
  9. window->setCentralWidget(centralWidget);
  10.  
  11. window->setWindowTitle("QLabel With Shadow");
  12. QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
  13. QLabel* label = new QLabel();
  14. sizePolicy.setHeightForWidth(label->sizePolicy().hasHeightForWidth());
  15. label->setSizePolicy(sizePolicy);
  16. label->setMinimumSize(QSize(0, 0));
  17. label->setMaximumSize(QSize(16777215, 16777215));
  18. label->setStyleSheet(QString::fromUtf8("font-size: 12px,0.2em; \n"
  19. "font-family: Segoe Regular; \n"
  20. "color: rgb(0, 0, 0);"));
  21. label->setText(QApplication::translate("EyGuiProgresColorUi", "Contrast", 0, QApplication::UnicodeUTF8));
  22.  
  23. gridLayout->addWidget(spinIt, 0, 2, 1, 1);
  24. gridLayout->addWidget(label, 0, 0, 1, 1);
  25. QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect();
  26. effect->setBlurRadius(0);
  27. effect->setColor(QColor(255, 0, 0));
  28. effect->setOffset(1,1);
  29. label->setGraphicsEffect(effect);
  30.  
  31. window->show();
  32.  
  33. return app.exec();
To copy to clipboard, switch view to plain text mode 

this sample application gives me what i require Normalized.png but not in my main application .
please help me what i might doing wrong ..?