• 5946阅读
  • 1回复

关于QFontMetrics类和painter。translation函数的具体用法~~~~ [复制链接]

上一主题 下一主题
离线061103121
 
只看楼主 倒序阅读 楼主  发表于: 2011-03-17
void Widget::paintOnWidget(QWidget *w)[pre]{[/pre][pre]    QPainter painter(w);[/pre][pre]    QFontMetrics metrics = painter.fontMetrics();  //这句的含义[/pre][pre]    int textHeight = metrics.ascent() + metrics.descent();//这句的含义[/pre][pre]    int leftWidth = metrics.width(tr("9000")) + 5;//这句的含义[/pre][pre][/pre][pre]    int rightWidth = metrics.width(tr("(日)"));//这句的含义[/pre][pre][/pre][pre]    int width = w->size().width() - leftWidth - rightWidth;//这句的含义[/pre][pre][/pre][pre]    int height = w->size().height() - 3 * textHeight;//这句的含义[/pre][pre] [/pre][pre] painter.translate(leftWidth, 1.75 * textHeight + height);//这句的含义[/pre][pre] [/pre][pre] [/pre]
离线longteng9
只看该作者 1楼 发表于: 2011-03-30
这个好像跟我用到了相同的代码
QFontMetrics metrics = painter->fontMetrics();
    int textHeight = metrics.ascent() + metrics.descent()-5;  //
    int leftWidth = metrics.width(tr("9000")) + 10;  
快速回复
限100 字节
 
上一个 下一个