void CommonHelper::setQLabelText(QLabel *label, const QString &text)
{
    QFontMetrics cs(label->font());
    int textWidth = cs.width(text);
    if(textWidth > label->width())
    {
        label->setToolTip(text);
    }
    else
    {
         label->setToolTip("");
    }

    QFontMetrics elideFont(label->font());
    label->setText(elideFont.elidedText(text, Qt::ElideRight, label->width()));
}

 

相关文章:

  • 2022-12-23
  • 2021-09-28
  • 2022-12-23
  • 2022-12-23
  • 2021-10-20
  • 2022-12-23
  • 2021-09-13
  • 2022-01-02
猜你喜欢
  • 2022-12-23
  • 2021-09-04
  • 2022-12-23
  • 2021-10-01
  • 2022-12-23
  • 2021-04-12
  • 2021-09-29
相关资源
相似解决方案