Stylesheet to Calender popup



  • how to give stylesheet to QDateEdit Calender popup?
    Is there any example I can go through??



  • Here is my example for customizing calendarWidget stylesheet

    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); 
    }
    

    Hope this can help!



  • @mostefa Thanks for this coustomization example. It is giving me controll for complete counstomization, but I am not able to set background color for the calender. Calender poped up after clicking on QDateEdit.



  • Hi @Sagar-Ojha

    In Qt Assistant stylesheet samples are provided.
    Search as : Qt Style Sheets Examples

    QString DEstylesheet = "QDateEdit { padding-right: 15px; border-width: 3;height : 30;font-size:20pt;color:#fff;"
            "background-color: qlineargradient(spread:pad, x1:0.517, y1:0, x2:0.517, y2:1, stop:0 rgba(45, 45, 45, 255), stop:0.505682 rgba(45, 45, 45, 255), stop:1 rgba(29, 29, 29, 255));}"
            ;
    
    m_DE       = new QDateEdit;
    m_DE->setStyleSheet(DEstylesheet);


  • @Sagar-Ojha

    Not sure i understand what do you want,

    background-color of calendarWidget , is already changed with my sample code:

    QCalendarWidget QAbstractItemView:enabled 
    {
    	font-size:24px;  
    	color: rgb(180, 180, 180);  
    	background-color: green;  // here background-color is changed !!!
    	selection-background-color: rgb(64, 64, 64); 
    	selection-color: rgb(0, 255, 0); 
    }
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.