QCalendar小部件选择颜色 [英] QCalendarWidget selection color

查看:1578
本文介绍了QCalendar小部件选择颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 QCalendar小工具和一些天的某些天是彩色的(例如假日是红色的)。当我选择一个有色的一天,选择清除颜色,我看不到它的原始颜色。但是当我取消选择那一天 - 颜色回来了。请参阅图片。

I have a QCalendarWidget and some days of month are colored (for example holidays are red). When I select a day which is colored, selection clears the color and I can't see it's original color. But when I deselect that day - color is back. Please see in pictures.

>

即使选择了一天,有办法保持颜色吗?我知道有一种方法可以为 QTableView 与代理,但我找不到这样的 QCalendarWidget 。有任何想法吗?感谢您的时间。

Is there a way to keep color even if a day is selected? I know that there is a way to do this for QTableView with delegates, but I can't find anything like this for QCalendarWidget. Any Ideas? Thank you for your time.

推荐答案

您可以访问内部 QTableView

QCalendarWidget *c = new QCalendarWidget;

QTableView *view = c->findChild<QTableView*>("qt_calendar_calendarview");
if (view)
{
    view->setItemDelegate(new MySuperCalendarDelegate);
}

然后你可以使用自定义委托来设置合适的背景和前景颜色。

Then you can use a custom delegate that will set proper background and foreground colors.

此外,您还可以在<$ c上查看我之前的回答 $ c> QCalendarWidget 样式。

Also you can check my previous answer on QCalendarWidget styling.

这篇关于QCalendar小部件选择颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆