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
Qt中获取文字的宽度和高度
最新推荐文章于 2023-06-28 12:50:14 发布