行背景颜色GtkTreeView小部件

行背景颜色GtkTreeView小部件

本文介绍了行背景颜色GtkTreeView小部件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为gtk树视图小部件中的禁用行着色为浅灰色.从我所读的内容中,我应该设置相应的cellrenderer的background-gdk属性并将其绑定到模型列.这种作品.

I'm attempting to color disabled rows in a gtk tree view widget a light gray color. From what I've read, I'm supposed to set the background-gdk property of the corresponding cellrenderer and bind it to a model column. This sort of works.

Gtk::CellRendererText* textRenderer = manage(new Gtk::CellRendererText());
textRenderer->property_editable() = false;
Gtk::TreeViewColumn *col = manage(new Gtk::TreeViewColumn("Column1", *textRenderer));
col->add_attribute(*textRenderer, "background-gdk", m_treeview_columns.m_back_color);
my_treeview.append_column(*col);

Gtk::TreeModel::Row row;
for (int i = 0; i < NUMBER_OF_ROWS; iLane++){
   row = *(treeview_liststore->append());
   row[m_workListColumns.m_back_color] = Gdk::Color("#CCCCCC");
}

最后,我只得到了正确着色的单元格.但是我在单元格之间也有一个难看的空白.有人知道解决此问题的方法或实现我所追求的效果的更好方法吗?

In the end though, I get only the cells colored properly. BUT I also get an ugly white-space in between the cells. Does anyone know of a way to fix this or a better way to achieve the effect I'm after?

推荐答案

您可以将行的背景设置为与单元格背景匹配还是将树视图的背景设置为全部?或者也许是带有cell-background-gdk的细胞?

Could you set the background of the row to match the cell background or set the bakground of the tree view all together ? Or maybe the cell with cell-background-gdk ?

这篇关于行背景颜色GtkTreeView小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 22:51