简体   繁体   English

GTK:通过按钮触发器最大化窗口的任何方法

[英]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). 顺便说一句,我正在使用GTK 3.0和C ++(不是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 检查是否使用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 该窗口是GtkWidget *类型

Note that as it was written GtkButton reference the callback have to look like that: 请注意,正如编写GtkButton参考一样,回调必须看起来像这样:

void user_function (GtkButton *button, gpointer user_data)

and you have type of callback int 并且您有回调int类型

For me both versions (with int and void callback works) 对我来说,这两个版本(都具有int和void回调函数)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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