我正在编写自己的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);
解决了第一个问题。第二个仍然没有解决。
答案 0 :(得分:2)
QAbstractItemView *view = findChild<QAbstractItemView*>();
if(view) {
view->setItemDelegate(//inherit QItemDelegate and override paint event);
}
答案 1 :(得分:0)
您的图标有不同的DPI版本吗?此页面讨论各种图标应该有多大: http://developer.android.com/design/style/iconography.html