简体   繁体   中英

GTK : Any way to mximize the window on Button trigger

Is there any callback function, so that when I click a button the window maximizes. By the way I'm using GTK 3.0 and C++ (Not gtkmm). I wrote a function which is called during the button click event and put this line

int maximise(){
gtk_window_fullscreen(GTK_WINDOW(window));
}

It gets compiled, but while I click the button the program terminates showing segmentation fault. (This function is inside the class)

Check whether the callback is called using ie g_print

Make sure that signal is correctly connected to the button

g_signal_connect (button, "clicked",
              G_CALLBACK (maximise), NULL);

And that window is GtkWidget * type

Note that as it was written GtkButton reference the callback have to look like that:

void user_function (GtkButton *button, gpointer user_data)

and you have type of callback int

For me both versions (with int and void callback works)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM