Dynamic text size QLabel

吃可爱长大的小学妹 提交于 2019-12-13 02:33:52

问题


What is the best way to determine if text-size exceeds width of QLabel? And according to that, change the text-size?

I have a QLabel with word-wrap option set to true, but when text is so long it is being cropped from left and right side.


回答1:


You might want to try this approach:

QLabel label;
QRect r = label.fontMetrics().boundingRect( "My text" ) );
int textWidth = r.width();


来源:https://stackoverflow.com/questions/36331651/dynamic-text-size-qlabel

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!