hakimingos
9th February 2010, 06:23
Hi everyone.
I developed the following main function:
#include <QtGui/QApplication>
#include <QPushButton>
#include <QCalendarWidget>
#include <QGraphicsDropShadowEffect>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget w;
w.resize(300, 300);
QApplication::setStyle("Plastic");
QPushButton *button = new QPushButton("OK", &w);
button->setGeometry(QRect(100, 30, 100, 40));
button->setStyleSheet("QPushButton { background-color: red; } QPushButton:hover { background-color: blue; }");
QGraphicsDropShadowEffect *effet = new QGraphicsDropShadowEffect(&w);
effet->setColor(QColor(0, 0, 0, 255));
effet->setBlurRadius(20);
button->setGraphicsEffect(effet);
//QCalendarWidget *calendrier = new QCalendarWidget(&w);
//calendrier->setGeometry(QRect(0, 100, 300, 200));
w.show();
return a.exec();
}
It will give as result (normal = red & hover = blue), like this
http://www.uploadgeek.com/thumb-B13F_4B706C5B.jpg (http://www.uploadgeek.com/share-B13F_4B706C5B.html) http://www.uploadgeek.com/thumb-FD6E_4B706C37.jpg (http://www.uploadgeek.com/share-FD6E_4B706C37.html)
QPushButton { background-color: red; } QPushButton:hover { background-color: blue; }
Now if we un comment the following two lines
QCalendarWidget * calendar = new QCalendarWidget (& w);
calendar-> addWidget (QRect (0, 100, 300, 200));
The code would be:
#include <QtGui/QApplication>
#include <QPushButton>
#include <QCalendarWidget>
#include <QGraphicsDropShadowEffect>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget w;
w.resize(300, 300);
QApplication::setStyle("Plastic");
QPushButton *button = new QPushButton("OK", &w);
button->setGeometry(QRect(100, 30, 100, 40));
button->setStyleSheet("QPushButton { background-color: red; } QPushButton:hover { background-color: blue; }");
QGraphicsDropShadowEffect *effet = new QGraphicsDropShadowEffect(&w);
effet->setColor(QColor(0, 0, 0, 255));
effet->setBlurRadius(20);
button->setGraphicsEffect(effet);
QCalendarWidget *calendrier = new QCalendarWidget(&w);
calendrier->setGeometry(QRect(0, 100, 300, 200));
w.show();
return a.exec();
}
In running we'll find this:
http://www.uploadgeek.com/thumb-8026_4B706C85.jpg (http://www.uploadgeek.com/share-8026_4B706C85.html)
So integrating the component QCalendarWidget (even QComboBox editable, table view, and others) the stylesheet of the button OK with effect would be inactive.
Now remove the effect of the OK button by commenting this line
button-> setGraphicsEffect (effect);
The code would be:
#include <QtGui/QApplication>
#include <QPushButton>
#include <QCalendarWidget>
#include <QGraphicsDropShadowEffect>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget w;
w.resize(300, 300);
QApplication::setStyle("Plastic");
QPushButton *button = new QPushButton("OK", &w);
button->setGeometry(QRect(100, 30, 100, 40));
button->setStyleSheet("QPushButton { background-color: red; } QPushButton:hover { background-color: blue; }");
QGraphicsDropShadowEffect *effet = new QGraphicsDropShadowEffect(&w);
effet->setColor(QColor(0, 0, 0, 255));
effet->setBlurRadius(20);
//button->setGraphicsEffect(effet);
QCalendarWidget *calendrier = new QCalendarWidget(&w);
calendrier->setGeometry(QRect(0, 100, 300, 200));
w.show();
return a.exec();
}
In running we'll find that the stylesheet function
So stylesheet "hover" + effect + Components "Qclaendar and other" = problem
The question is, how to resolve this problem?
thank you in advance ;)
I developed the following main function:
#include <QtGui/QApplication>
#include <QPushButton>
#include <QCalendarWidget>
#include <QGraphicsDropShadowEffect>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget w;
w.resize(300, 300);
QApplication::setStyle("Plastic");
QPushButton *button = new QPushButton("OK", &w);
button->setGeometry(QRect(100, 30, 100, 40));
button->setStyleSheet("QPushButton { background-color: red; } QPushButton:hover { background-color: blue; }");
QGraphicsDropShadowEffect *effet = new QGraphicsDropShadowEffect(&w);
effet->setColor(QColor(0, 0, 0, 255));
effet->setBlurRadius(20);
button->setGraphicsEffect(effet);
//QCalendarWidget *calendrier = new QCalendarWidget(&w);
//calendrier->setGeometry(QRect(0, 100, 300, 200));
w.show();
return a.exec();
}
It will give as result (normal = red & hover = blue), like this
http://www.uploadgeek.com/thumb-B13F_4B706C5B.jpg (http://www.uploadgeek.com/share-B13F_4B706C5B.html) http://www.uploadgeek.com/thumb-FD6E_4B706C37.jpg (http://www.uploadgeek.com/share-FD6E_4B706C37.html)
QPushButton { background-color: red; } QPushButton:hover { background-color: blue; }
Now if we un comment the following two lines
QCalendarWidget * calendar = new QCalendarWidget (& w);
calendar-> addWidget (QRect (0, 100, 300, 200));
The code would be:
#include <QtGui/QApplication>
#include <QPushButton>
#include <QCalendarWidget>
#include <QGraphicsDropShadowEffect>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget w;
w.resize(300, 300);
QApplication::setStyle("Plastic");
QPushButton *button = new QPushButton("OK", &w);
button->setGeometry(QRect(100, 30, 100, 40));
button->setStyleSheet("QPushButton { background-color: red; } QPushButton:hover { background-color: blue; }");
QGraphicsDropShadowEffect *effet = new QGraphicsDropShadowEffect(&w);
effet->setColor(QColor(0, 0, 0, 255));
effet->setBlurRadius(20);
button->setGraphicsEffect(effet);
QCalendarWidget *calendrier = new QCalendarWidget(&w);
calendrier->setGeometry(QRect(0, 100, 300, 200));
w.show();
return a.exec();
}
In running we'll find this:
http://www.uploadgeek.com/thumb-8026_4B706C85.jpg (http://www.uploadgeek.com/share-8026_4B706C85.html)
So integrating the component QCalendarWidget (even QComboBox editable, table view, and others) the stylesheet of the button OK with effect would be inactive.
Now remove the effect of the OK button by commenting this line
button-> setGraphicsEffect (effect);
The code would be:
#include <QtGui/QApplication>
#include <QPushButton>
#include <QCalendarWidget>
#include <QGraphicsDropShadowEffect>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget w;
w.resize(300, 300);
QApplication::setStyle("Plastic");
QPushButton *button = new QPushButton("OK", &w);
button->setGeometry(QRect(100, 30, 100, 40));
button->setStyleSheet("QPushButton { background-color: red; } QPushButton:hover { background-color: blue; }");
QGraphicsDropShadowEffect *effet = new QGraphicsDropShadowEffect(&w);
effet->setColor(QColor(0, 0, 0, 255));
effet->setBlurRadius(20);
//button->setGraphicsEffect(effet);
QCalendarWidget *calendrier = new QCalendarWidget(&w);
calendrier->setGeometry(QRect(0, 100, 300, 200));
w.show();
return a.exec();
}
In running we'll find that the stylesheet function
So stylesheet "hover" + effect + Components "Qclaendar and other" = problem
The question is, how to resolve this problem?
thank you in advance ;)