`

Qt中获取文字的宽度和高度

    博客分类:
  • Qt
阅读更多
QFontMetrics fm = painter->fontMetrics();
QPrinter *printer = new QPrinter;
mPixelPerCentimeter = printer->resolution()/2.54;
foreach(QString str,szTable)
{
	double tempWidth = fm.width(str)/mPixelPerCentimeter;
	width = qMax(tempWidth,width);
}					
double height = fm.height()/mPixelPerCentimeter*szTable.size();//mutiply line
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics