回复: QLabel有没有一个属性,在setText以后自适应改变尺寸,不用每次调用adjustSize的?
#6 回 kaon 的帖子 [ustone 05-22 06:10]
kaon:https://stackoverflow.com/questions/13994902/how-do-i-get-a-qlabel-to-expand-to-full-width
看下这个 (2018-05-21 18:28)
他说的是full width,我要的是最紧凑的width,因为我的label设置了背景色,长了不好看。
#7 [songhuirong1 05-22 10:49]
scaledContents : bool
This property holds whether the label will scale its contents to fill all available space.
When enabled and the label shows a pixmap, it will scale the pixmap to fill the available space.
This property's default is false.
Access functions:
bool
hasScaledContents() const
void
setScaledContents(bool)
#8 回 songhuirong1 的帖子 [ustone 05-22 18:20]
songhuirong1:scaledContents : bool
This property holds whether the label will scale its contents to fill all available space.
When enabled and the label shows a pixmap, it will scale the pixmap to fill the available space.
This property's default is false.
Access funct .. (2018-05-22 10:49)
谢谢,这个是显示图片而且自动缩放图片的,我想要的是显示字符串,而且自动调整width以刚好容纳字符串。
#9 [llwj0303 08-06 11:10]
l楼主最后解决了吗,遇到同样的问题