PDA

View Full Version : Using style sheets on QDateEdit



jgver
6th October 2011, 22:49
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:


QDateEdit {
border: 2px solid lightgray;
border-radius: 5px;
}

QDateEdit::drop-down {
subcontrol-origin: padding;
subcontrol-position: top right;
width: 15px;

border-left-width: 1px;
border-left-color: darkgray;
border-left-style: solid;
border-top-right-radius: 3px;
border-bottom-right-radius: 3px;
}

QDateEdit::down-arrow {
image: url(:/DateEditTest/Resources/Combobox Arrow.png);
}

QDateEdit::drop-down:hover {
/* Does this work with QDateEdit??? */
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #d8d7d7, stop: 1 #e9e9e9);
}


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!

wysota
7th October 2011, 21:20
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).

aM101kS
30th January 2018, 08:35
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);
}