从Gtk::TreeStore中删除图像的时髦方法
Tidy way to delete image from Gtk::TreeStore
我有一个带有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
在"dir_columns.stock_id"中找到Gtk::CellRendererPixbuf"translates"到位于树中的图像。当我像这样将图像添加到行中时:
//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
属性。
相关文章:
- 访问随机图像像素的快速方法,最多一次
- 在RAW图像中提取RGB通道值的库或方法
- 是否有一种标准化的方法通过TCP/IP网络发送JPG图像
- Tesseract/Lebonica处理单页和多页图像的正确方法
- OpenCv 在C++中从 1 D 数组制作垫子图像的最快方法
- 在Qt5中缩放高DPI图像的最佳方法是什么?
- 尝试使用 Qt 库中的 QPixmap 将图像拆分为多个块。关于他的复制方法的工作方式,我有什么不明白的吗?
- C++显示图像并将其保持到下一张图像的最佳方法
- 使用某些系数将图像转换为灰度的最快方法
- 使用OpenCV检测图像中垂直文本的方法
- 沿非连续维度对图像进行装箱的最快方法
- 从C 中的文件中读取图像,然后传递到Libharu的绘制方法
- 使用C++和OpenGL显示图像的正确方法
- C++方法中的图像旋转
- 在amd64体系结构上的C++中,将图像缓冲区blit到另一个缓冲区的xy偏移中的最快方法
- 在C++中,在图像周围填充黑色边框是最有效的方法
- 调用Qpainter的方法绘制以刷新图像和更改颜色
- QT,C++:在QGraphicsview上从相机绘制实时图像流的快速方法
- 从Gtk::TreeStore中删除图像的时髦方法
- QT是否有其他方法可以在没有QTNetworkManager的情况下加载图像