Results 1 to 1 of 1

Thread: Problem stylesheet with effect

  1. #1
    Join Date
    Feb 2010
    Posts
    1
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi PyQt3 PyQt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Problem stylesheet with effect

    Hi everyone.

    I developed the following main function:

    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include <QPushButton>
    3. #include <QCalendarWidget>
    4. #include <QGraphicsDropShadowEffect>
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QApplication a(argc, argv);
    9. w.resize(300, 300);
    10.  
    11. QApplication::setStyle("Plastic");
    12.  
    13. QPushButton *button = new QPushButton("OK", &w);
    14. button->setGeometry(QRect(100, 30, 100, 40));
    15. button->setStyleSheet("QPushButton { background-color: red; } QPushButton:hover { background-color: blue; }");
    16.  
    17. QGraphicsDropShadowEffect *effet = new QGraphicsDropShadowEffect(&w);
    18. effet->setColor(QColor(0, 0, 0, 255));
    19. effet->setBlurRadius(20);
    20.  
    21. button->setGraphicsEffect(effet);
    22.  
    23. //QCalendarWidget *calendrier = new QCalendarWidget(&w);
    24. //calendrier->setGeometry(QRect(0, 100, 300, 200));
    25.  
    26. w.show();
    27. return a.exec();
    28. }
    To copy to clipboard, switch view to plain text mode 

    It will give as result (normal = red & hover = blue), like this



    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:

    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include <QPushButton>
    3. #include <QCalendarWidget>
    4. #include <QGraphicsDropShadowEffect>
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QApplication a(argc, argv);
    9. w.resize(300, 300);
    10.  
    11. QApplication::setStyle("Plastic");
    12.  
    13. QPushButton *button = new QPushButton("OK", &w);
    14. button->setGeometry(QRect(100, 30, 100, 40));
    15. button->setStyleSheet("QPushButton { background-color: red; } QPushButton:hover { background-color: blue; }");
    16.  
    17. QGraphicsDropShadowEffect *effet = new QGraphicsDropShadowEffect(&w);
    18. effet->setColor(QColor(0, 0, 0, 255));
    19. effet->setBlurRadius(20);
    20.  
    21. button->setGraphicsEffect(effet);
    22.  
    23. QCalendarWidget *calendrier = new QCalendarWidget(&w);
    24. calendrier->setGeometry(QRect(0, 100, 300, 200));
    25.  
    26. w.show();
    27. return a.exec();
    28. }
    To copy to clipboard, switch view to plain text mode 

    In running we'll find this:



    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:

    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include <QPushButton>
    3. #include <QCalendarWidget>
    4. #include <QGraphicsDropShadowEffect>
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QApplication a(argc, argv);
    9. w.resize(300, 300);
    10.  
    11. QApplication::setStyle("Plastic");
    12.  
    13. QPushButton *button = new QPushButton("OK", &w);
    14. button->setGeometry(QRect(100, 30, 100, 40));
    15. button->setStyleSheet("QPushButton { background-color: red; } QPushButton:hover { background-color: blue; }");
    16.  
    17. QGraphicsDropShadowEffect *effet = new QGraphicsDropShadowEffect(&w);
    18. effet->setColor(QColor(0, 0, 0, 255));
    19. effet->setBlurRadius(20);
    20.  
    21. //button->setGraphicsEffect(effet);
    22.  
    23. QCalendarWidget *calendrier = new QCalendarWidget(&w);
    24. calendrier->setGeometry(QRect(0, 100, 300, 200));
    25.  
    26. w.show();
    27. return a.exec();
    28. }
    To copy to clipboard, switch view to plain text mode 
    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
    Last edited by hakimingos; 9th February 2010 at 06:28.

Similar Threads

  1. Replies: 1
    Last Post: 5th October 2009, 16:40
  2. Replies: 6
    Last Post: 9th July 2009, 08:11
  3. QListWidget - stylesheet problem
    By febil in forum Qt Programming
    Replies: 3
    Last Post: 23rd February 2009, 16:44
  4. StyleSheet Problem with QTabWidget
    By December in forum Qt Programming
    Replies: 1
    Last Post: 8th August 2007, 22:16
  5. Stylesheet (css) problem
    By madcama in forum Newbie
    Replies: 1
    Last Post: 4th December 2006, 22:41

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.