GtkLabel Wrapped Huge Height

auto widget=gtk_label_new(text);
m_handle=GTK_LABEL(widget);
gtk_label_set_line_wrap(m_handle,TRUE);
gtk_label_set_max_width_chars(m_handle,80);
gtk_widget_set_size_request(GTK_WIDGET(m_handle),-1,1);

      

And, the label wraps, but GTK thinks the widget requires a height equal to the line break after each word. And no, I cannot shrink the window manually. How to restore its height?

Huge window

+3


source to share


1 answer


Although I'm not at all familiar with Gtk3 programming, I've seen a very similar phenomenon in Qt5.

What I think is happening is that Gtk3 will set the minimum height of the label to the height it would have on completion to the minimum width. I mean the minimum width of the label itself, so even if the window cannot be shrunk, the label could potentially be if other widgets appear next to it.

This mechanism is described here: https://developer.gnome.org/gtk3/stable/GtkWidget.html#geometry-management



Note:

Minimum height minimum width is usually used to set minimum size constraint at the top level (except for gtk_window_set_geometry_hints () explicitly used).

So, you can try setting a minimum width limit on the label itself and see if that changes.

+4


source







All Articles