gpt4 book ai didi

c - 如何在 C 中突出显示 GTKTreeView 行,就像用鼠标选择一样

转载 作者:行者123 更新时间:2023-11-30 16:06:20 25 4
gpt4 key购买 nike

我要么看得太深了,要么是别的什么。我有一个从文件填充的简单 GTKTreeVew。行数由 CSV 文件中的行数决定。

我可以从循环中的每一行获取数据,但似乎可以掌握如何突出显示该行。我可以选择它获取它的路径并 printf 行号,但不知道如何在代码中突出显示它...

selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtk_tree_view));
if (gtk_tree_selection_get_selected(selection, &model, &iter))
{
path = gtk_tree_model_get_path (model, &iter);
path_string = gtk_tree_path_to_string (path);
row = atoi(path_string);
set_active_test_row_single(row);

printf("\nSelected ROW is %d\n", row);

}

感谢任何链接、反馈等。似乎找不到“突出显示”行号的功能。当用鼠标单击一行时会发生相同的“突出显示”。

最佳答案

我通过谷歌搜索大约一周并看到其他语言的类似示例,终于弄清楚了。

void single_button_clicked_cb(GtkWidget *widget, gpointer data)
{
static int index = 0;
GtkTreeIter iter;
char buf[9];
GtkTreeModel *model;
GtkAdjustment *vadjustment;
int i;

printf("\nScroll Active test row to %d\n",index);

sprintf(buf,"%d",index);

gtk_widget_grab_focus (GTK_WIDGET(gtk_tree_view));

GtkTreePath *path = gtk_tree_path_new_from_string(buf);

gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW (gtk_tree_view),path, NULL,FALSE, 0.0, 0.0);

gtk_tree_view_set_cursor (gtk_tree_view,path,NULL,FALSE); // works but doesn't scroll

gtk_tree_path_free(path);

index++;
}

关于c - 如何在 C 中突出显示 GTKTreeView 行,就像用鼠标选择一样,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59994490/

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