V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
amazingwujun
V2EX  ›  Qt

Qt 中的 `QFontMetrics.boundingRect()` 算出来的文本长度有时候会不对,应该如何处理。

  •  
  •   amazingwujun · Jun 9, 2023 · 3652 views
    This topic created in 1057 days ago, the information mentioned may be changed or developed.
    3 replies    2023-07-07 11:39:13 +08:00
    tomatolq
        1
    tomatolq  
       Jun 9, 2023
    QFontMetrics.boundingRect 对于有空格的数据 会有问题 还是要看场景 我的做法是 算出来结果 加上 10 像素 能满足我的需求
    amazingwujun
        2
    amazingwujun  
    OP
       Jun 12, 2023
    我目前的处理也是加上一个固定的长度,谢谢
    goingjack
        3
    goingjack  
       Jul 7, 2023
    horizontalAdvance 应该没问题
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1473 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 16:23 · PVG 00:23 · LAX 09:23 · JFK 12:23
    ♥ Do have faith in what you're doing.