amazingwujun
V2EX  ›  Qt

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

  •  
  •   amazingwujun · Jun 9, 2023 · 4999 views
    This topic created in 1107 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   ·   790 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 58ms · UTC 21:27 · PVG 05:27 · LAX 14:27 · JFK 17:27
    ♥ Do have faith in what you're doing.