Java JXTable有一个列控件让用户显示/隐藏列。
QTableView有没有类似的东西?我知道有 an API call to show/hide a column ,但是当您使用带有 QTableView 的程序时,这没有帮助。
最佳答案
使用表中的水平标题并调用隐藏部分传递您要隐藏的索引,我将其链接到上下文菜单中的信号,该信号获取右键单击的列的索引
table_view->horizontalHeader()->hideSection(index);
编辑:和显示列类似
table_view->horizontalHeader()->showSection(index);
从 QPoint 获取索引(我从请求上下文菜单的位置获取索引)
int index = table_view->horizontalHeader()->logicalIndexAt(cursor_pos);
关于python - QTableView 列控件方便显示/隐藏列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25366830/