0
点赞
收藏
分享

微信扫一扫

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

中间件小哥 2023-04-11 阅读 73


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

举报

相关推荐

0 条评论