我的应用程序的用户有一个奇怪的问题,QCalendarWidget不能正确地在标题中呈现日期名称。你可以在这个截图上看到它:

问题是我不能重现这个。有谁知道原因是什么吗?Qt版本为5.3.0。
我不想盲目地增加应用程序中每个日历小部件的宽度。
发布于 2016-08-15 23:58:55
qcalendarwidget trabaja con el tamaño de la fuente del elemento
QAbstractItemView
los的表的重建。Entonces...dabo el ancho del widget,se puede hacer un loop para cual es el tamaño de letra que对应一个简单的ancho y luego resize:
//ancho objetivo
int calendarWidth = dateDialog_width*.4;
//altura minima necesaria para satisfacer el ancho objetivo
int calendarHight;
int daysFontSize=0;
QSize size;
//voy probando el font size hasta pasarme del ancho objetivo
do
{
daysFontSize++;
calendar->setStyleSheet(QString("QCalendarWidget QAbstractItemView:enabled{font-size:%1px;}").arg(daysFontSize));
size = calendar->minimumSizeHint();
}
while(size.width()<calendarWidth);
//ancho final
calendarWidth = size.width();
//alto final sin botones
calendarHight = size.height();
//porcion del widget que ocupan los botones(en %)
int buttonsHeightPercent = 25;
//pixels del widget que ocupan los botones
int buttonsHeight = calendarHight*buttonsHeightPercent/(100-buttonsHeightPercent);
//agrego la altura de los botones a la altura minima
calendarHight+=buttonsHeight;
//resize
this->calendar->setFixedWidth(calendarWidth);
this->calendar->setFixedHeight(calendarHight);干杯!"el conocimiento pertenece al mundo“
https://stackoverflow.com/questions/26703755
复制相似问题