Search code examples
buttongtktooltip

Add tooltip to GtkButton


I want to add a tooltip to a GtkButton.
This seems like an easy thing to do, except I have no idea why is not working. What I have:
1)

GtkButton* button = gtk_button_new_with_label("button");   
gtk_widget_set_tooltip_text(button, "tooltip text");

2)

GtkButton* button = gtk_button_new_with_label("button"); 
GtkTooltips *button_bar_tips = gtk_tooltips_new();
gtk_tooltips_set_tip(GTK_TOOLTIPS (button_bar_tips), 
                     button , "tooltip text", NULL);

Tried both with

gtk_widget_set_has_tooltip(button, true);

but still no luck. Any ideas? thks!


Solution

  • Well, GtkTooltips are deprecated now so let skip option 2), as for option 1) it looks completely right to me ...

    So first, make sure you dont mix both approaches, maybe this is a problem...