amazingwujun
V2EX  ›  Qt

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

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