문제

I tried passing a two-dimensional array as argument to a function in GTK, without success. How can I edit the order of the buttons in the array?

GtkWidget *botones[4][4];

...

g_signal_connect(G_OBJECT(botones[0][0]), "clicked", G_CALLBACK(borra), botones);

...

void borra(GtkWidget *widget, gpointer info)
 {
    GtkWidget **elementos= (GtkWidget*) info;

     ...

 }
도움이 되었습니까?

해결책

botones is a 4*4 array of GtkWidget *, when you call g_signal_connect, you cast it to a gpointer which is typedef for void *, then in the callback function, you should cast the gpointer back to a pointer to an array of 4 GtkWidget * like this:

GtkWidget * (*elementos)[4] = (GtkWidget *(*)[4])info;

Then you can use elementos[0][0] to access the 2-D array.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top