当前位置: 技术问答>linux和unix
GTK+ 问题
来源: 互联网 发布时间:2016-04-08
本文导语: g_signal_connect_swapped ((gpointer) button1, "clicked", G_CALLBACK (on_button1_clicked), GTK_OBJECT (label1)); void on_button1_clicked ...
g_signal_connect_swapped ((gpointer) button1, "clicked",
G_CALLBACK (on_button1_clicked),
GTK_OBJECT (label1));
void
on_button1_clicked (GtkButton *button,
gpointer user_data)
{
//在这里我应该如何使用label1这个控件,比如我要改变label1 的内容
}
|
user_data就是你的label1
直接指针转换 GtkWidget * label = GTK_LABEL(user_data);
然后就随便你怎么蹂躏label了……
比如
gtk_label_set_text(GTK_LABEL(label),"Hello Boy");
直接指针转换 GtkWidget * label = GTK_LABEL(user_data);
然后就随便你怎么蹂躏label了……
比如
gtk_label_set_text(GTK_LABEL(label),"Hello Boy");
|
楼上的可能也对,但没用过,下面两行可能管用
GtkWidget *label = lookup_widget (GTK_WIDGET (button),"label1");
gtk_label_set_text(GTK_LABEL(label),"Hello");
GtkWidget *label = lookup_widget (GTK_WIDGET (button),"label1");
gtk_label_set_text(GTK_LABEL(label),"Hello");