Hide widget if parent window width <widget.width ?
-
wrote on 11 Nov 2019, 18:40 last edited by
Hey
I'd like to hide a widget if the parent widget/window/other widget width is below a certain point. I have some "useless" labels that I'd like to hide to allow for more comfortable work.
Does QT offer anything like that
-
Hi,
Something like QSplitter ?
-
wrote on 11 Nov 2019, 18:56 last edited by
@SGaist said in Hide widget if parent window width <widget.width ?:
Hi,
Something like QSplitter ?
I don't want to manually hide the widget. Just automatically hide when empty space runs out.
Say I have window that is 400 wide and 4 widgets that take 200 pixels. if window.width()<200, then one of the 4 widgets should disappear and the remaining 3 become wider to show data better. I suppose all widgets with flag to auto-hide should disappear at once... mhmhmmm Something tells me Qt does not have it o.O
-
AFAIK, no it does not. However one thing that is sure is that you should handle that in the widget containing those that should be made invisible and not the other way around.
-
AFAIK, no it does not. However one thing that is sure is that you should handle that in the widget containing those that should be made invisible and not the other way around.
wrote on 11 Nov 2019, 21:34 last edited by@SGaist I ended up hocking up to resize event of parent widget to find out when size changed & resize my other widget acordingly.
I ended up using "invisible" QLabel that retains size as my "spacer". I had to change its spacing role on the go depending of one or more widget are visible or not as I needed to retain correct order. So far works great.
TIA
3/5