11
QString str = QString::number((double)i, 'd', 1);
painter->drawText(100 + i * 800/9 - 6, 910, 40, 40, 0, str );

我想将 fontSize 增加到 2x 显示什么?

4

3 回答 3

26

您可以尝试这样的事情(尚未编译代码以查看它是否有效!):

QFont font = painter->font() ;

/* twice the size than the current font size */
font.setPointSize(font.pointSize() * 2);

/* set the modified font to the painter */
painter->setFont(font);

/* draw text etc. */
painter.drawText(....);
于 2013-07-23T19:57:55.610 回答
6

弄清楚了:

QFont font;
font.setPixelSize(12);

for(int i = 0; i < 10; i++){
    painter->drawLine(100, 100 + i * 800/9, 900, 100 + i * 800/9);
    str = QString::number((double)9 - i, 'd', 1);
    painter->setFont(font);
    painter->drawText(75, 100 + i * 800/9 - 6, 40, 40, 1, str);
}
于 2013-07-23T19:57:14.597 回答
3

这是最简单的方法

painter.setFont(QFont("times",22)); //22 is a number which you have to change
于 2016-08-15T12:40:24.827 回答