width = label.fontMetrics().boundingRect(label.text()).width();
获取QLabel文本的像素长度
原文:https://www.cnblogs.com/tingtaishou/p/14631187.html