QString str = QString::number((double)i, 'd', 1);
painter->drawText(100 + i * 800/9 - 6, 910, 40, 40, 0, str );
我想将fontSize增加到显示的2倍?
答案 0 :(得分:20)
您可以尝试这样的事情(没有编译代码以查看它是否有效!):
QFont font = painter->font() ;
/* twice the size than the current font size */
font.setPointSize(font.getPointSize() * 2);
/* set the modified font to the painter */
painter->setFont(font);
/* draw text etc. */
painter.drawText(....);
答案 1 :(得分:3)
想出来:
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);
}
答案 2 :(得分:2)
这是最简单的方法
painter.setFont(QFont("times",22)); //22 is a number which you have to change