c -如何设置占位符文本在GtkEntry



我试了这个例子:

#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
GdkPixbuf *create_pixbuf(const gchar * filename) {    
    GdkPixbuf *pixbuf;
    GError *error = NULL;
    pixbuf = gdk_pixbuf_new_from_file(filename, &error);
    if(!pixbuf) {       
        fprintf(stderr, "%sn", error->message);    g_error_free(error);            
    }
    return pixbuf; 
}
void implement() {    
    printf("HI"); 
}    
int main( int argc, char *argv[]) {    
    GtkWidget *window;
    GtkWidget *frame;
    GtkWidget *label;
    GtkWidget *text;    
    gtk_init(&argc, &argv);
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(window), "New Message");
    gtk_window_set_default_size(GTK_WINDOW(window), 310, 390);
    gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
    gtk_window_set_icon(GTK_WINDOW(window), create_pixbuf("web.png"));
    frame = gtk_fixed_new();
    gtk_container_add(GTK_CONTAINER(window), frame);        
    text = gtk_entry_new();
    gtk_entry_set_max_length (GTK_ENTRY (text), 0);
    gtk_entry_set_width_chars (GTK_ENTRY (text), 37);
    gtk_entry_set_placeholder_text(GTK_ENTRY (text), "Send a message");
    gtk_fixed_put(GTK_FIXED(frame), text, 2, 360);      
    gtk_widget_show_all(window);        
    g_signal_connect(window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
    gtk_main();
    return 0;    
}
undefined reference to gtk_entry_set_placeholder_text' '

确保您的GTK+版本是3.2或更高版本,因为该特定函数是在那时添加的。

相关内容

  • 没有找到相关文章

最新更新