Last active
July 9, 2021 05:00
-
-
Save andrey-str/0f9c7709cbf0c9c49ef9 to your computer and use it in GitHub Desktop.
Set "Elided....Text" to QLabel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setElidedText(QLabel* label, const QString &text){ | |
QFontMetrics metrix(label->font()); | |
int width = label->width() - 2; | |
QString clippedText = metrix.elidedText(text, Qt::ElideMiddle, width); | |
label->setText(clippedText); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment