How do I update Labels in GTK+-3.0 in C

后端 未结 2 531
野趣味
野趣味 2021-01-24 06:07

I can\'t seem to be able to use the function

gtk_label_set_text();

this is what I write:

#include 

int main(         


        
2条回答
  •  感动是毒
    2021-01-24 06:42

    As per the [ prototype ] , gtk_label_set_text expects GtkLabel* as its first parameter, so change

    gtk_label_set_text(label, "I cannot use this func");
    

    to

    gtk_label_set_text((GtkLabel*)label, "I cannot use this func");
    

    or more conveniently

    gtk_label_set_text(GTK_LABEL(label), "I cannot use this func");
    

    In fact GTK_LABEL() macro expands to :

    #define GTK_LABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_LABEL, GtkLabel))
    

    in the header gtklabel.h.

提交回复
热议问题