无法连接Glade GTK + 3中的信号和信号处理程序 [英] Unable to connect signal and signal handler in Glade GTK+3
问题描述
您好,我正在开发Ubuntu 14.04 LTS上的GTK + 3项目。我试图使用Glade,但是当我尝试将切换按钮的切换信号连接到一个名为kaczka的函数后,编译后我在控制台中得到了这个:(Gra_w_Statki:11072):Gtk - 警告**:找不到信号处理程序'kaczka。您是否使用-rdynamic进行编译?
窗口和按钮呈现自身并正常工作,但切换按钮不会改变任何内容。我做错了什么?
这是我试图连接切换按钮和功能的方式点击!
我的链接器设置为: pkg-config --libs gtk + -3.0
我的编译器设置是: pkg-config --cflags gtk + -3.0
我使用Code :: Blocks 13.12和GCC编译器。
这是我的代码:
#include
#include< gtk / gtk.h>
void kaczka(GtkToggleButton * tbutton,gpointer data)
{
gtk_main_quit();
$ b int main(int argc,char * argv [])
{
GtkWidget * win = NULL;
GtkBuilder * builder;
gtk_init(& argc,& argv);
builder = gtk_builder_new();
gtk_builder_add_from_file(builder,kaczka.glade,NULL);
win = GTK_WIDGET(gtk_builder_get_object(builder,window1));
gtk_builder_connect_signals(builder,NULL);
g_object_unref(G_OBJECT(builder));
gtk_widget_show_all(win);
gtk_main();
返回0;
}
a href =https://developer.gnome.org/gtk3/stable/GtkBuilder.html#gtk-builder-connect-signals =nofollow> gtk_builder_connect_signals()和 gtk_builder_add_callback_symbol()文档。基本上,您需要在连接之前在所有回调中使用 gtk_builder_add_callback_symbol()
- 信号或
- 与gmodule-export-2.0链接,并使用编译标志-Wl, - export-dynamic来导出甚至未使用的符号。
ul>
Hi i'm working on a project in GTK+ 3 on Ubuntu 14.04 LTS. I'm trying to use Glade,but when i tried to connect a "toggled" signal of toggle button to a function called kaczka ,after compiling i got this in my console: (Gra_w_Statki:11072): Gtk-Warning**:Could not find signal handler 'kaczka. Did you compile with -rdynamic?
The window and the button render itself and work normally except of that toggling button doesn't change anything. What am i doing wrong ?
This is how i tried to connect toggle button and function Click!
My Linker Settings are : pkg-config --libs gtk+-3.0
And my compiler settings are: pkg-config --cflags gtk+-3.0
I'm using Code ::Blocks 13.12 with GCC compiler.
And this is my code:
#include <stdlib.h>
#include <gtk/gtk.h>
void kaczka (GtkToggleButton *tbutton, gpointer data)
{
gtk_main_quit ();
}
int main (int argc, char *argv[])
{
GtkWidget *win = NULL;
GtkBuilder *builder;
gtk_init (&argc, &argv);
builder=gtk_builder_new();
gtk_builder_add_from_file( builder, "kaczka.glade", NULL);
win=GTK_WIDGET(gtk_builder_get_object(builder,"window1"));
gtk_builder_connect_signals( builder, NULL );
g_object_unref( G_OBJECT( builder ) );
gtk_widget_show_all (win);
gtk_main ();
return 0;
}
Take a look at the gtk_builder_connect_signals() and gtk_builder_add_callback_symbol() documentation. Basically you need to either
- use
gtk_builder_add_callback_symbol()
on all callbacks before connecting the signals or - link with gmodule-export-2.0 and use compile flags "-Wl,--export-dynamic" to export even unused symbols.
这篇关于无法连接Glade GTK + 3中的信号和信号处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!