如何去掉GtkTreeView排序箭头?
我需要从列标题中删除排序箭头。 这可以通过调用 set_sort_indicator(false)
。
箭头没有显示,但它的空间似乎仍然被保留。 如果列的标题足够大以填充所有标题,则最后一部分将被剪裁(箭头应在的位置)。
有没有办法让标题填满整个标题?
I need to remove the sorting arrow from a column header. This can be done by calling set_sort_indicator(false)
on the column.
The arrow isn't displayed, but the space for it seems to still be reserved. If the title of the column is big enough to fill all the header, the last part is clipped (where the arrow should be).
Is there a way to make the title fill the whole header?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这在 GTK+ 中似乎有点奇怪。 我下载并通读了 GtkTreeViewColumn 代码的相关部分,并且它似乎使用了这个逻辑:
其中
arrow
是持有箭头的小部件。 这似乎表明箭头小部件总是被打包到构成列标题的水平框中,然后如果它不应该可见,则将其隐藏(而不是删除)。 这意味着它仍然在盒子里,占据空间并导致标签被剪掉。我建议通过 GTK+ bugtracker 搜索与此相关的问题,如果没有找到,则创建一个。
This seems to be a bit weird in GTK+. I downloaded and read through relevant parts of the GtkTreeViewColumn's code, and it seems to use this logic:
Where
arrow
is the widget holding the arrow. This seems to indicate that the arrow widget is always packed into the horizontal box that makes up the column's header, and then just hidden (not removed) if it's not supposed to be visible. That will mean it's still there in the box, occupying space and causing the label to be clipped.I'd recommend searching through the GTK+ bugtracker for an issue about this, and if none is found, create one.
好的,我已经向 gtk 提交了错误报告。 他们说这不是问题,也不会得到解决。
我看过其他图形工具包(windows、qt),它们的实现是不同的,但这对于 gtk 团队的人来说似乎并不重要。
Ok, so I've submitted a bug report to gtk. They said that it is not an issue and it won't be fixed.
I've looked on other graphical toolkits (windows, qt) and their implementation is different, but this doesn't seem to matter to the guys in the gtk team.
好的,您可以对列使用
set_clickable
方法您不希望它有箭头然后使用
signal_connect
到clicked
信号并将其绑定到 函数,该函数将使用get_sort_column_id
获取当前排序然后使用set_sort_column_id
应用反向排序顺序。Ok you can use
set_clickable
method to the the column you don't want it to have an arrowthen use
signal_connect
to theclicked
signal and bind it to a function which will useget_sort_column_id
to get the current sort order then apply the reverse sort order usingset_sort_column_id
.