首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

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

2012-12-18 
Qt中获取文字的宽度和高度QFontMetrics fm painter-fontMetrics()QPrinter *printer new QPrinterm

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

热点排行