티스토리 뷰

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);


'Qt > Classes' 카테고리의 다른 글

QMessageBox Code Examples  (0) 2017.05.19
QSettings Code Examples  (0) 2017.05.07
QTreeView QTreeWidget Code Examples  (0) 2017.05.02
QDate, QDateTime Code Examples  (0) 2017.05.02
QString Code examples  (0) 2017.05.01
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
글 보관함