GTK3 : Not able to resize window below its contents dimension

Hi,

I’m working on GTK3 application in cpp. I’m trying to handle window resize event.

I have a Window, whose size is set using gtk_window_set_default_size, and it has some contents whose size is set using gtk_widget_set_size_request. The contents dimensions are set to completely fit windows dimensions.

Im handling the “configure-event” signal and resizing the contents respectively when the window is resized. Its working when I increase the window size but not while decreasing the window size
gtk

Window is not getting resized when I decrease the window below its contents dimensions. How to fix this ?

Thank you,
Harshithraj P

Don’t use gtk_widget_set_size_request().

It sets the minimum size of the widget, which propagates up to the window. That is, if you set it after every window resize, you are telling that the window now must not be smaller than the new size (in other words: you disallow shrinking).

Instead, you should use the hexpand/vexpand/halign/valign properties to make the content fill its parent.

Thank you for the response. We have a project model where all the dimensions to the widgets come from different module, we must dimension our widgets with respect to those values. So is there any other way to fix this issue?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.