Cでボタンの配列を作成する必要があります。私は何が欠けているか分からないので、助けてください。そして最後に、私はこれはおそらくない最良の方法このi++;
を行うそれから私は、ボタンの残りの部分を作成ボタンの配列を作成する
GtkWidget *button[5];
int i;
for (i =1; i<5; i++)
button[i] = gtk_button_new();
が...私はとbutton [i]
を使用していますが、私はちょうどその時わからない:ここに私の配列であります配列を作成し、残りのステートメントでボタン1、ボタン2などをどのように渡しますか? ご了承ください。 p.s.私は、Cに新しいです私に厳しいことがいけない、TY :)
/* Creates a new button with the label "Button 1". */
button[i] = gtk_button_new_with_label ("Button 1");
/* Now when the button is clicked, we call the "callback" function
* with a pointer to "button 1" as its argiument */
g_signal_connect (button[i], "clicked",
G_CALLBACK (callback), "Run button 1");
/* Instead of gtk_container_add, we pack this button into the invisible
* box, which has been packed into the window. */
gtk_box_pack_start (GTK_BOX (box1), button[i], TRUE, TRUE, 0);
/* Always remember this step, this tells GTK that our preparation for
* this button is complete, and it can now be displayed. */
gtk_widget_show (button[i]);
i++;
配列インデックス値は0から始まります。例えば、for(i = 0; i <5; i ++)です。 – adatapost
私は5つのボタンが必要です... –
まあ、i <5の場合はTRUE、i = 5の場合はFALSEなぜAVDが正しいのかが分かります。 – liberforce