wagmare
14th February 2014, 09:45
I was trying to add shadow effect in the qlabel using QGraphicsDropShadowEffect. so i added the effect like this .
QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect();
effect->setBlurRadius(0);
effect->setColor(QColor(255, 0, 0));
effect->setOffset(1,1);
label1->setGraphicsEffect(effect);
but the effect is looking weird as for other widget like spinbox it is working proper .
10045 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
QApplication app(argc,argv);
QMainWindow* window = new QMainWindow();
QWidget* centralWidget = new QWidget();
QSpinBox *spinIt = new QSpinBox;
QGridLayout *gridLayout = new QGridLayout;
centralWidget->setLayout(gridLayout);
window->setCentralWidget(centralWidget);
window->setWindowTitle("QLabel With Shadow");
QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
QLabel* label = new QLabel();
sizePolicy.setHeightForWidth(label->sizePolicy().hasHeightForWidth());
label->setSizePolicy(sizePolicy);
label->setMinimumSize(QSize(0, 0));
label->setMaximumSize(QSize(16777215, 16777215));
label->setStyleSheet(QString::fromUtf8("font-size: 12px,0.2em; \n"
"font-family: Segoe Regular; \n"
"color: rgb(0, 0, 0);"));
label->setText(QApplication::translate("EyGuiProgresColorUi", "Contrast", 0, QApplication::UnicodeUTF8));
gridLayout->addWidget(spinIt, 0, 2, 1, 1);
gridLayout->addWidget(label, 0, 0, 1, 1);
QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect();
effect->setBlurRadius(0);
effect->setColor(QColor(255, 0, 0));
effect->setOffset(1,1);
label->setGraphicsEffect(effect);
window->show();
return app.exec();
this sample application gives me what i require 10046 but not in my main application .
please help me what i might doing wrong ..?
QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect();
effect->setBlurRadius(0);
effect->setColor(QColor(255, 0, 0));
effect->setOffset(1,1);
label1->setGraphicsEffect(effect);
but the effect is looking weird as for other widget like spinbox it is working proper .
10045 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
QApplication app(argc,argv);
QMainWindow* window = new QMainWindow();
QWidget* centralWidget = new QWidget();
QSpinBox *spinIt = new QSpinBox;
QGridLayout *gridLayout = new QGridLayout;
centralWidget->setLayout(gridLayout);
window->setCentralWidget(centralWidget);
window->setWindowTitle("QLabel With Shadow");
QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
QLabel* label = new QLabel();
sizePolicy.setHeightForWidth(label->sizePolicy().hasHeightForWidth());
label->setSizePolicy(sizePolicy);
label->setMinimumSize(QSize(0, 0));
label->setMaximumSize(QSize(16777215, 16777215));
label->setStyleSheet(QString::fromUtf8("font-size: 12px,0.2em; \n"
"font-family: Segoe Regular; \n"
"color: rgb(0, 0, 0);"));
label->setText(QApplication::translate("EyGuiProgresColorUi", "Contrast", 0, QApplication::UnicodeUTF8));
gridLayout->addWidget(spinIt, 0, 2, 1, 1);
gridLayout->addWidget(label, 0, 0, 1, 1);
QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect();
effect->setBlurRadius(0);
effect->setColor(QColor(255, 0, 0));
effect->setOffset(1,1);
label->setGraphicsEffect(effect);
window->show();
return app.exec();
this sample application gives me what i require 10046 but not in my main application .
please help me what i might doing wrong ..?