如何去掉GtkTreeView排序箭头?

发布于 2024-07-21 09:01:19 字数 325 浏览 4 评论 0原文

我需要从列标题中删除排序箭头。 这可以通过调用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

橪书 2024-07-28 09:01:19

这在 GTK+ 中似乎有点奇怪。 我下载并通读了 GtkTreeViewColumn 代码的相关部分,并且它似乎使用了这个逻辑:

  if (tree_column->show_sort_indicator ||
       (GTK_IS_TREE_SORTABLE (model) && tree_column->sort_column_id >= 0))
    gtk_widget_show (arrow);
  else
    gtk_widget_hide (arrow);

其中 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:

  if (tree_column->show_sort_indicator ||
       (GTK_IS_TREE_SORTABLE (model) && tree_column->sort_column_id >= 0))
    gtk_widget_show (arrow);
  else
    gtk_widget_hide (arrow);

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.

半边脸i 2024-07-28 09:01:19

好的,我已经向 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.

最终幸福 2024-07-28 09:01:19

好的,您可以对列使用 set_clickable 方法您不希望它有箭头
然后使用 signal_connectclicked 信号并将其绑定到 函数,该函数将使用 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 arrow
then use signal_connect to the clicked signal and bind it to a function which will use get_sort_column_id to get the current sort order then apply the reverse sort order using set_sort_column_id.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文