yvs2014
(Yvs2014)
November 30, 2023, 9:26am
1
It seems that gtk_label_set_width_chars()
disables horizontal alignment which set with gtk_widget_set_halign()
. Removing gtk_label_set_width_chars() returns that horizontal alignment.
Is there a way to set both (width and h.alignment) for GTK label?
p.s. GTK4
set_width_chars()
will set a minimum width for your Label.
But by default the text itself will still be centered.
You can use gtk_label_set_xalign()
to align the text within the widget’s allocation.
1 Like
ebassi
(Emmanuele Bassi)
November 30, 2023, 10:48am
3
Additionally, you may need to set the GtkWidget:hexpand
property on the label in order to tell the label’s parent to allocate extra room for it.
1 Like
yvs2014
(Yvs2014)
November 30, 2023, 10:58am
4
it works with halign combining:
alignment to left:
gtk_label_set_width_chars()
gtk_widget_set_halign(, GTK_ALIGN_START) + gtk_label_set_xalign(, 0)
alignment to right:
gtk_label_set_width_chars()
gtk_widget_set_halign(, GTK_ALIGN_END) + gtk_label_set_xalign(, 1)
Thank you very much, that what I wanted to achieve
system
(system)
Closed
January 14, 2024, 10:58am
5
This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.