相关疑难解决方法(0)

PyQt - QTableView中的复选框列

我正在从Pandas数据帧动态创建QTableView.我这里有示例代码.

我可以使用复选框创建表格,但是我无法获得反映模型数据的复选框,甚至根本无法更改为取消选中.

我正在关注上一个问题的示例代码,并以@raorao答案为指导.这将显示表格中的框,但不起作用.

任何人都可以建议任何更改,或者此代码有什么问题.为什么它不反映模型,为什么它不会改变?

请查看我的完整示例代码.

编辑一:Frodon评论后更新:更正了字符串强制转换为bool并进行比较xxx =='True'

class CheckBoxDelegate(QtGui.QStyledItemDelegate):
    """
    A delegate that places a fully functioning QCheckBox in every
    cell of the column to which it's applied
    """
    def __init__(self, parent):
        QtGui.QItemDelegate.__init__(self, parent)

    def createEditor(self, parent, option, index):
        '''
        Important, otherwise an editor is created if the user clicks in this cell.
        ** Need to hook up a signal to the model
        '''
        return None

    def paint(self, painter, option, index):
        '''
        Paint …
Run Code Online (Sandbox Code Playgroud)

python pyqt python-2.7 pandas

11
推荐指数
2
解决办法
1万
查看次数

标签 统计

pandas ×1

pyqt ×1

python ×1

python-2.7 ×1