2014-11-04 59 views
4

我正在編寫我自己的QCalendarWidget實現。我希望日期可以選擇,但我不想看到默認的選擇矩形。它看起來像: enter image description here如何刪除QCalendarWidget中的選定日期矩形和小部件中的小圖標

而且我的代碼:

in constructor: setSelectionMode(SingleSelection); 

void ShiftCalendar::paintCell(QPainter *painter, const QRect &rect, const QDate &date) const 
{ 
     if(date == selectedDate()) { 
      fillCell(painter, rect, CalendarWidget::cellFillColor); 
     } 

     drawCellText(painter, rect, QString::number(date.day()), color); 
} 

void ShiftCalendar::fillCell(QPainter *painter, const QRect &rect, const QColor &color) const 
{ 
    painter->save(); 

    painter->setRenderHint(QPainter::Antialiasing); 
    painter->setPen(QPen(color)); 
    painter->setBrush(QBrush(color)); 
    painter->drawEllipse(fRect.center(), rect.width()/2, rect.height()/2); 

    painter->restore(); 
} 

我能做些什麼?

在圖片中可以看到的第二個問題是按鈕圖標和組合框圖標的小尺寸。它在桌面上看起來不錯,但在Android上它一直很小。修改圖標大小沒有任何影響。

編輯:

與添加selection-background-color: rgba(0, 0, 0, 0);到Widget的樣式表解決了第一個問題。第二個仍然沒有解決。

+0

什麼圖標的類型?圖標的實際大小是多少? – Robert 2014-11-12 14:07:37

+0

這些是PNGs 128x128 – micnyk 2014-11-13 15:03:39

+0

我知道轉儲的問題,但是,你有沒有指定一個大小? QML,... ?? – Robert 2014-11-13 15:20:16

回答

2
QAbstractItemView *view = findChild<QAbstractItemView*>(); 

if(view) { 

    view->setItemDelegate(//inherit QItemDelegate and override paint event); 
} 
相關問題