Qt/Classes
QFontMetrics Code Examples
아침엔커피한잔
2017. 5. 2. 12:06
http://doc.qt.io/qt-5/QFontMetrics.html
int QFontMetix::width(QChar ch) const; int QFontMetix::width(const QString &text, int len, int flags) const; int QFontMetix::width(const QString &text, int len = -1) const; QLabel testLabel("레이블 테스트입니다."); QFontMetrix fontMetrics(testLabel.font()); const int horizontalMargin = 10; int labelWidth = fontMetrics.width(testLabel.text()) + widthMargin; testLabel.setFixedWidth(labelWidth); QLabel testLabel("레이블 테스트입니다."); testLabel.setFixedWidth(100); QFontMetrix fontMetrics(testLabel.font()); QString strElidedText = fontMetrics.elidedText( testLabel.text(), Qt::ElideMiddle, testLabel.width()); testLabel.setText(strElidedText);