【问题标题】:pyqt qt4 qTableView disable the grid line for a specific columnpyqt qt4 qTableView 禁用特定列的网格线
【发布时间】:2014-03-28 04:22:30
【问题描述】:

我尝试使用 qt 样式表来定位特定列。

在 HTML CSS 中你可以做这样的事情

table.players td:nth-child(N) { /* ... */ }

查看文档,我找不到针对特定 qTableView 列的方法

http://qt-project.org/doc/qt-4.8/stylesheet.html

http://qt-project.org/doc/qt-4.8/stylesheet-reference.html

http://qt-project.org/doc/qt-4.8/stylesheet-syntax.html

我认为在这个例子中我可以用数字替换部分来定位特定的列,但我认为我不明白它在做什么

http://qt-project.org/doc/qt-4.8/stylesheet-examples.html#customizing-qtableview

QTableView QTableCornerButton::section {
   background: red;
   border: 2px outset red;
}

如果 qt 样式表无法做到这一点,那么重写paint方法并重用Qt代码的最佳方法是什么?

【问题讨论】:

    标签: qt pyqt qtableview qtstylesheets


    【解决方案1】:

    实现此目的的一种方法是使用 QItemDelegate 来呈现每个单元格。有几个 c++ 示例可以翻译成 Python 代码:

    How can I set the line style of a specific cell in a QTableView?

    How do I assign a border to a specific QTableWidgetItem or a row in a QTableWidget?

    在您的情况下,您可以使用模型索引(直接或从模型中查找数据)来确定为每个单元格绘制哪种边框以及何时根本不绘制。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-22
      • 1970-01-01
      • 2013-07-18
      • 2011-08-20
      • 2012-04-18
      • 2018-10-23
      相关资源
      最近更新 更多