2
我想要做一個GTK 2+中的下拉菜單,並且我得出的結論是它們被稱爲「gtk_combo_box」。但是,每當我嘗試編譯,它給了我丟失的參數的函數錯誤...Gtk組合框函數缺少參數和表達式
這裏是一個重要的部分代碼:
vbox3_field = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (hbox2), vbox3_field);
gtk_box_pack_start (GTK_BOX (hbox2), vbox3_field, FALSE, TRUE, 0);
vbox3_sett = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (hbox2), vbox3_sett);
ball_menu=gtk_combo_box_text_new();
gtk_combo_box_text_append_text (GtkComboBoxText ball_menu, "1");
gtk_combo_box_text_append_text (GtkComboBoxText ball_menu, "2");
gtk_combo_box_set_active (GtkComboBox *combo_box, 0);
//g_signal_connect (ball_menu, "changed", G_CALLBACK (cb_ball_selection), gtk_combo_box_text_get_active_text());
gtk_box_pack_start(GTK_BOX (vbox3_sett), ball_menu);
當我嘗試採取「GtkComboBoxText」出來的函數參數,它仍然給我一個警告,說不兼容的指針類型。 (我宣佈「ball_menu」爲GtkWidget * ball_menu)。
的功能被定義爲遵循GTK 2+參考網站:
void
gtk_combo_box_text_append_text (GtkComboBoxText *combo_box,
const gchar *text);
以下是編譯的結果:
gcc -o main main.c `pkg-config --cflags --libs gtk+-2.0` -lm
main.c: In function ‘main’:
main.c:265:35: error: expected expression before ‘GtkComboBox’
gtk_combo_box_text_append_text (GtkComboBoxText ball_menu, "1");
^
main.c:265:35: error: too few arguments to function ‘gtk_combo_box_text_append_text’
In file included from /usr/include/gtk-2.0/gtk/gtk.h:74:0,
from main.c:1:
/usr/include/gtk-2.0/gtk/gtkcomboboxtext.h:63:15: note: declared here
void gtk_combo_box_text_append_text (GtkComboBoxText *combo_box,
^
main.c:266:35: error: expected expression before ‘GtkComboBoxText’
gtk_combo_box_text_append_text (GtkComboBoxText ball_menu, "2");
^
main.c:266:35: error: too few arguments to function ‘gtk_combo_box_text_append_text’
In file included from /usr/include/gtk-2.0/gtk/gtk.h:74:0,
from main.c:1:
/usr/include/gtk-2.0/gtk/gtkcomboboxtext.h:63:15: note: declared here
void gtk_combo_box_text_append_text (GtkComboBoxText *combo_box,
^
main.c:267:29: error: expected expression before ‘GtkComboBox’
gtk_combo_box_set_active (GtkComboBox *combo_box, 0);
^
main.c:267:29: error: too few arguments to function ‘gtk_combo_box_set_active’
In file included from /usr/include/gtk-2.0/gtk/gtk.h:72:0,
from main.c:1:
/usr/include/gtk-2.0/gtk/gtkcombobox.h:101:15: note: declared here
void gtk_combo_box_set_active (GtkComboBox *combo_box,
^
有誰知道要做到這一點的原因是什麼?
好,它的工作,謝謝。 請注意,對於gtk_combo_box_set_active,演員似乎是GTK_COMBO_BOX。 – Kelthar