QString str = QString::number((double)i, 'd', 1);
painter->drawText(100 + i * 800/9 - 6, 910, 40, 40, 0, str);
我想將fontSize增加到2x顯示什麼?如何更改drawText上的字體大小?
QString str = QString::number((double)i, 'd', 1);
painter->drawText(100 + i * 800/9 - 6, 910, 40, 40, 0, str);
我想將fontSize增加到2x顯示什麼?如何更改drawText上的字體大小?
想通了:
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);
}
你可以嘗試這樣的事情(未編譯的代碼,看看它是否有效!):
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(....);
In may case: '''font.setPointSize(font.pointSize()* 2);''' – danger89
這是最簡單的方式
painter.setFont(QFont("times",22)); //22 is a number which you have to change
如果你有一個不同於默認**的字體**,它可能會重置它而不是隻是修改它的大小。 –
setFont不應該在for循環中... – Troyseph