QLabel in a layout: check whether or not setText() will cause the layout to expand
-
I have a
QLabel
and aQComboBox
in a horizontal layout. The problem is that when I put long text in the label, it causes the layout to expand, which leads to the whole main window expanding. I want to avoid that by compacting the text if necessary, but how can I check before hand whether or notsetText
call will stretch the window?Note: I don't care if QLabel becomes longer than it was. I only care whether or not the main window will be expanded because of that.
-
-
Hi,
Calculating width is no problem. But how can I know if the window will be expanded or not? The way I see it, I need to calculate the new width, and then ask the layout if setting this width will make it expand.
-
@Violet-Giraffe why not compare the label's width and the calculated width of the text?