gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 19:19:59 25 4
gpt4 key购买 nike

我尝试了这个例子:

#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, "%s\n", 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 gtk_entry_set_placeholder_text'`

最佳答案

确保您的 GTK+ 版本为 3.2 或更高版本,因为那时添加了该特定功能。

关于c - 如何在 GtkEntry 中设置占位符文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23470502/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com