Skip to content

Instantly share code, notes, and snippets.

@andrey-str
Last active July 9, 2021 05:00
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save andrey-str/0f9c7709cbf0c9c49ef9 to your computer and use it in GitHub Desktop.
Save andrey-str/0f9c7709cbf0c9c49ef9 to your computer and use it in GitHub Desktop.
Set "Elided....Text" to QLabel
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