直接上代码:

void Adjust(QLabel * lb)
{
    QFont font(lb->font());
    while(1)
    {
        QFontMetrics fontMetrics(font);
        int nFontWidth = fontMetrics.horizontalAdvance(lb->text());

        if(nFontWidth<lb->width())
        {
            break;
        }

        font.setPointSize(font.pointSize()-1);
    }
    lb->setFont(font);
}

 

相关文章:

  • 2022-01-12
  • 2021-07-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
猜你喜欢
  • 2021-08-19
  • 2021-11-06
  • 2021-10-13
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
  • 2021-12-29
相关资源
相似解决方案