void Widget::paintOnWidget(QWidget *w)[pre]{[/pre][pre] QPainter painter(w);[/pre][pre] QFontMetrics metrics = painter.fontMetrics(); //这句的含义[/pre][pre] int textHeight = metrics.ascent() + metrics.descent();//这句的含义[/pre][pre] int leftWidth = metrics.width(tr("9000")) + 5;//这句的含义[/pre][pre][/pre][pre] int rightWidth = metrics.width(tr("(日)"));//这句的含义[/pre][pre][/pre][pre] int width = w->size().width() - leftWidth - rightWidth;//这句的含义[/pre][pre][/pre][pre] int height = w->size().height() - 3 * textHeight;//这句的含义[/pre][pre] [/pre][pre] painter.translate(leftWidth, 1.75 * textHeight + height);//这句的含义[/pre][pre] [/pre][pre] [/pre]