我想在Qt中创建一个表,该表可以折叠并将其行扩展为组(行按特定列的内容分组),例如:
所有组展开:
第一组崩溃:
当点击“组标题行”时,所有“子行”要么折叠成“组标题行”,要么显示在它下面。 该表还应该能够“联合国”本身,成为一个正常的表。在
我尝试过将QTreeView与QTableWidget一起作为子窗口小部件使用,但是将这些表“取消分组”到单个表中就成了一个问题。在
我还尝试使用QTableView并将“groupheaderrows”添加到表中。这有点管用,但要正确实现它却非常困难,因为它涉及到移动行并插入这些行为与其他行完全不同的“伪行”,从而搞乱了底层的QStandardItemModel。这也使得排序变得异常复杂。在
有没有更好的方法来实现这种小部件,或者可能已经存在一个标准的Qt小部件来实现这种功能?我想我最终可以用我当前的QTableView使用“假行”(也许),但是到目前为止,它很容易被破坏,而且很难实现,所以我真的需要一个更好的解决方案。。。在
在这种情况下,应使用QTreeView,如下例所示:
相关问题 更多 >
编程相关推荐