Results 1 to 3 of 3

Thread: Using style sheets on QDateEdit

  1. #1
    Join Date
    Aug 2008
    Location
    Eastern U.S.
    Posts
    9
    Thanks
    1
    Qt products
    Qt4 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Using style sheets on QDateEdit

    Hello,

    I am trying to use a style sheet on a QDateEdit widget, with the calendar popup flag turned on. I am trying to set a color for a hover event over the drop-down arrow.

    Here is the style sheet I am using:
    Qt Code:
    1. border: 2px solid lightgray;
    2. border-radius: 5px;
    3. }
    4.  
    5. QDateEdit::drop-down {
    6. subcontrol-origin: padding;
    7. subcontrol-position: top right;
    8. width: 15px;
    9.  
    10. border-left-width: 1px;
    11. border-left-color: darkgray;
    12. border-left-style: solid;
    13. border-top-right-radius: 3px;
    14. border-bottom-right-radius: 3px;
    15. }
    16.  
    17. QDateEdit::down-arrow {
    18. image: url(:/DateEditTest/Resources/Combobox Arrow.png);
    19. }
    20.  
    21. QDateEdit::drop-down:hover {
    22. /* Does this work with QDateEdit??? */
    23. background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #d8d7d7, stop: 1 #e9e9e9);
    24. }
    To copy to clipboard, switch view to plain text mode 

    What I'm seeing is that the drop-down part doesn't change color when the mouse is hovered over it. If you take the same style sheet and use it on a QComboBox (ie, use the same style sheet code but change all QDateEdit strings to QComboBox), it works perfectly. (I noticed that if you move the mouse over the QDateEdit's drop-down part quickly, it does actually change color sometimes, though not too often.)

    So, my question is: is there additional styling that needs to be done for QDateEdit widgets?

    Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Using style sheets on QDateEdit

    I don't think QDateEdit::drop-down supports :hover. You can verify that in the stylesheet reference though. Maybe you should try to style QCalendarWidget instead? That's what the popup is (I think).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3

    Cool Re: Using style sheets on QDateEdit

    hi , u can use this
    QCalendarWidget QToolButton {
    height: 60px;
    width: 150px;
    color: white;
    font-size: 24px;
    icon-size: 56px, 56px;
    background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop: 0 #cccccc, stop: 1 #333333);
    }
    QCalendarWidget QMenu {
    width: 150px;
    left: 20px;
    color: white;
    font-size: 18px;
    background-color: rgb(100, 100, 100);
    }
    QCalendarWidget QSpinBox {
    width: 150px;
    font-size:24px;
    color: white;
    background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop: 0 #cccccc, stop: 1 #333333);
    selection-background-color: rgb(136, 136, 136);
    selection-color: rgb(255, 255, 255);
    }
    QCalendarWidget QSpinBox::up-button { subcontrol-origin: border; subcontrol-position: top right; width:65px; }
    QCalendarWidget QSpinBox::down-button {subcontrol-origin: border; subcontrol-position: bottom right; width:65px;}
    QCalendarWidget QSpinBox::up-arrow { width:56px; height:56px; }
    QCalendarWidget QSpinBox::down-arrow { width:56px; height:56px; }

    /* header row */
    QCalendarWidget QWidget { alternate-background-color: rgb(128, 128, 128); }

    /* normal days */
    QCalendarWidget QAbstractItemView:enabled
    {
    font-size:24px;
    color: rgb(180, 180, 180);
    background-color: black;
    selection-background-color: rgb(64, 64, 64);
    selection-color: rgb(0, 255, 0);
    }

    /* days in other months */
    /* navigation bar */
    QCalendarWidget QWidget#qt_calendar_navigationbar
    {
    background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop: 0 #cccccc, stop: 1 #333333);
    }

    QCalendarWidget QAbstractItemView:disabled
    {
    color: rgb(64, 64, 64);
    }

Similar Threads

  1. Style Sheets
    By yakuzan in forum Newbie
    Replies: 5
    Last Post: 29th May 2010, 10:11
  2. Do Qt Style Sheets support List-style-image?
    By daiheitan in forum Qt Programming
    Replies: 6
    Last Post: 12th March 2010, 02:41
  3. style sheets
    By alisami in forum Qt Programming
    Replies: 8
    Last Post: 7th May 2009, 10:41
  4. Qt style sheets
    By locus in forum Qt Programming
    Replies: 5
    Last Post: 5th April 2007, 18:03
  5. style sheets
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 29th March 2007, 16:14

Tags for this Thread

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.