gpt4 book ai didi

c - GTK+ :How to communicating between GtkWindow?

转载 作者:行者123 更新时间:2023-11-30 17:31:15 25 4
gpt4 key购买 nike

我想在两个 TOPLEVEL GtkWindow 之间进行通信。 例如,我双击GtkTreeView中的行,新的GtkWindow用于修改该行的上下文。 但是,除了声明一个全局变量来传递结构体之外,我没有找到解决方案。我是否可以找到一个巧妙的方法来帮助我解决问题? 作为 GTK 的新手,我将感谢您的帮助。

最佳答案

您可以通过“行激活”信号传递数据:

this_window = gtk_window_new (mode);
that_window = gtk_window_new (mode);
tv = gtk_tree_view_new ();

g_object_connect (tv, "row_activated",
G_CALLBACK (on_row_activate), that_window);



static mode my_func_using_data (view, that_window)
{
// do something here to pass a data to view
....
....
selection = view.get_selection ()
GtkTreeModel *model;
GtkTreeIter iter;
if ( gtk_tree_selection_get_selected (selection))
{
// modify the data here with model and iter
}

}
static void on_row_activate (GtkTreeView *view,
GtkTreePath *path,
GtkTreeViewColumn *col,
gpointer that_window)
{
my_func_using_data (view, that_window)
}

关于c - GTK+ :How to communicating between GtkWindow?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24720462/

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