Qt QTreeWidget - 禁用单个列的交互 [英] Qt QTreeWidget - disabling interaction for a single column

查看:561
本文介绍了Qt QTreeWidget - 禁用单个列的交互的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以禁用交互或只是对 QTreeWidget 中的特定行进行排序?我有一个表,其中如果您单击标题,它排序项目。我有一个自定义 CTreeWidgetItem 其中我已经重载< operator 对我的数据执行自定义排序。问题是,它排在我点击的每个标题,而不只是第一列。我需要它只工作在第一列。是否有我可以做的事?

is there a way to disable interaction or just sorting for a specific row in a QTreeWidget? I have a table where if you click the header, it sorts the items. I have a custom "CTreeWidgetItem" where I have overloaded the < operator to perform a custom sort on my data. The problem is, it sorts on every header I click, not just the first column. I need it to only work for the first column. Is there something I can do?

推荐答案

只需连接到 sectionClicked() 标题的信号( QTreeView: :header())。然后将排序指示器强制回到第一部分 QHeaderView :: setSortIndicator()

Simply connect to the sectionClicked() signal of the header (QTreeView::header()). Then force the sort indicator back to the first section QHeaderView::setSortIndicator().

这篇关于Qt QTreeWidget - 禁用单个列的交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆