gpt4 book ai didi

c++ - 从 Gtk::TreeStore 中删除图像的整洁方法

转载 作者:行者123 更新时间:2023-11-28 08:00:59 28 4
gpt4 key购买 nike

我有一个带有 Gtk::TreeView 的对话窗口。此对话框显示主文件系统树并提供选择磁盘上文件夹的选项。当用户选择某个文件夹时,我将 Gtk::Stock 图像添加到代表该文件夹的行。

为此,我创建了一个与树的最后一列关联的 Gtk::CellRendererPixbuf:

//appending columns
directory_tree.append_column("Folder List", dir_columns.name);
Gtk::TreeViewColumn *column = directory_tree.get_column(0);
if(column) column->set_expand(true);
Gtk::CellRendererPixbuf *cell = Gtk::manage(new Gtk::CellRendererPixbuf);
directory_tree.append_column("", *cell);
column = directory_tree.get_column(1);
if(column) column->add_attribute(cell->property_stock_id(), dir_columns.stock_id);

这段代码的链接:https://github.com/mc-suchecki/Imagine/blob/master/gui/dialogs.cpp#L47

Gtk::CellRendererPixbuf '翻译' Gtk::StockId 在 'dir_columns.stock_id' 中找到到位于树中的图像。当我像这样将图像添加到行时:

//selecting folder
(*folder)[fs_columns.stock_id] = Gtk::StockID(Gtk::Stock::FIND).get_string();
(*folder)[fs_columns.included] = true;

一切正常,但是当我尝试以这种方式删除图像时:

//unselecting folder
(*folder)[fs_columns.stock_id] = "";
(*folder)[fs_columns.included] = false;

图像正确地消失了,但是在命令行中有一些这样的错误(这不是确切的消息,我会在我能够启动我的应用程序时发布它):

(imagine:9376): Gtk-WARNING **: Gtk StockId not found 

当然警告的原因很明显(没有与空白名称关联的 StockId 项目),但是我的问题是:有没有办法从 Gtk::TreeView 行中删除不会生成任何 Gtk 警告的图像?

我取消选择文件夹的代码在这里: https://github.com/mc-suchecki/Imagine/blob/master/core/core.cpp#L207

非常感谢您,对不起我的英语。

最佳答案

如果您想去掉图像,请将 visible 属性更改为 false,而不是将 stock-id 属性更改为 false。

关于c++ - 从 Gtk::TreeStore 中删除图像的整洁方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11470607/

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