gpt4 book ai didi

C++,将 g_signal_connect 事件正确添加到按钮

转载 作者:行者123 更新时间:2023-11-28 02:51:21 27 4
gpt4 key购买 nike

我使用 gtk 创建了一个窗口。然后我想向按钮添加点击事件。我尝试了几种方法但没有成功

#if GTK_CHECK_VERSION(3,0,0)
GtkBuilder* builder = newDialogBuilder("smartart.ui");
#else
GtkBuilder* builder = newDialogBuilder("smartart-2.ui");
#endif
window = GTK_WIDGET(gtk_builder_get_object(builder, "smartartDlg"));
spin = GTK_WIDGET(gtk_builder_get_object(builder, "summarySpin"));
m_btOk=GTK_WIDGET(gtk_builder_get_object(builder, "btOk"));
m_btClose=GTK_WIDGET(gtk_builder_get_object(builder, "btClose"));

然后我尝试使用下面的代码添加一个信号

 g_signal_connect (GTK_DIALOG (m_btClose), "response",G_CALLBACK(Smartart__onCloseClicked),NUll);

然后它编译但给出了运行时错误

我的 Smartart__onCloseClicked 方法如下

void
Smartart__onCloseClicked (GtkButton * /*button*/,gpointer data)
{
fprintf(stderr, "Close button clicked");
}

最佳答案

GtkButton 点击​​的正确事件应该是clicked

g_signal_connect (G_OBJECT (m_btClose), "clicked",G_CALLBACK(Smartart__onCloseClicked),NULL);

引用:GtkButton reference

关于C++,将 g_signal_connect 事件正确添加到按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22981978/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com