LoginSignup
1
0

More than 3 years have passed since last update.

QTableWidget の指定列をReadOnly にするStyledItemDelegate

Posted at

備忘録かつ添削をお願いしたく投稿します。
C++の例を書き換えたStyledItemDelegateを書いてみました。
ReadOnlyStyledItemDelegateです。

ReadOnlyStyledItemDelegate.py
from PySide2.QtWidgets import QStyledItemDelegate

class ReadOnlyStyledItemDelegate(QStyledItemDelegate):
    def __init__(self, parent=None):
        super().__init__(parent)

    def createEditor(self, parent, option, index):
        return None

特定列更新不可は実務的には必要な機能だろうと思います。
C++の例がnull返しなのだから、Noneで良いのでは?という程度の理解で書いてます。
createできないのだからdelegateが実装すべき後の機能は親任せで良いだろうということで、createEditorのみです。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0