ItemDataRole 编号 31 (PySide/PyQt) 是什么?

What is ItemDataRole number 31 (PySide/PyQt)?

在我重新实现 QStandardItem 时,我正在实现 setData。我了解角色通常是如何工作的,以及它们的整数表示(请参阅下面的文档完整枚举),但我得到的角色不在通常的枚举中:具有常量 31[=29 的角色=].这个神秘的无证角色是什么?

这是我的 QStandardItem 子类(注意这不是我实际使用的东西,只是为了让这个问题更清楚):

class StandardItem(QtGui.QStandardItem):
    def setData(self, newValue, role=QtCore.Qt.UserRole + 1):
        if role == QtCore.Qt.EditRole:
            print "setData for editRole"
            QtGui.QStandardItem.setData(self, newValue, role)
            return True
        if role == QtCore.Qt.CheckStateRole:
            print "setData for check state role"
            QtGui.QStandardItem.setData(self, newValue, role)
            return True
        print "setData for other cases, with role ", role
        QtGui.QStandardItem.setData(self, newValue, role)

总的来说,我看到的东西是合理的,除了我在查看我的模型时看到角色编号 31 也打印出来了:

setData for check state role
setData for other than editRole:  31

enumeration of the roles 中,我没有找到角色 31(我 cut/paste 整个角色列表,以防我完全迟钝):

Role        Constant    Desc
Qt.DisplayRole  0   The key data to be rendered in the form of text. (QString)
Qt.DecorationRole   1   The data to be rendered as a decoration in the form of an icon. (QColor, QIcon or QPixmap)
Qt.EditRole     2   The data in a form suitable for editing in an editor. (QString)
Qt.ToolTipRole  3   The data displayed in the item's tooltip. (QString)
Qt.StatusTipRole    4   The data displayed in the status bar. (QString)
Qt.WhatsThisRole    5   The data displayed for the item in "What's This?" mode. (QString)
Qt.SizeHintRole     13  The size hint for the item that will be supplied to views. (QSize)
Qt.FontRole     6   The font used for items rendered with the default delegate. (QFont)
Qt.TextAlignmentRole    7   The alignment of the text for items rendered with the default delegate. (Qt.AlignmentFlag)
Qt.BackgroundRole   8   The background brush used for items rendered with the default delegate. (QBrush)
Qt.BackgroundColorRole  8   This role is obsolete. Use BackgroundRole instead.
Qt.ForegroundRole   9   The foreground brush (text color, typically) used for items rendered with the default delegate. (QBrush)
Qt.TextColorRole    9   This role is obsolete. Use ForegroundRole instead.
Qt.CheckStateRole   10  This role is used to obtain the checked state of an item. (Qt.CheckState)
Qt.InitialSortOrderRole     14  This role is used to obtain the initial sort order of a header view section. (Qt.SortOrder). This role was introduced in Qt 4.8.
Qt.AccessibleTextRole   11  The text to be used by accessibility extensions and plugins, such as screen readers. (QString)
Qt.AccessibleDescriptionRole    12  A description of the item for accessibility purposes. (QString)
Qt.UserRole     32  The first role that can be used for application-specific purposes.

有人知道31是什么角色吗?

src/corelib/global/qnamespace.h:

enum ItemDataRole {
    DisplayRole = 0,
    DecorationRole = 1,
    EditRole = 2,
    ToolTipRole = 3,
    StatusTipRole = 4,
    WhatsThisRole = 5,
    // Metadata
    FontRole = 6,
    TextAlignmentRole = 7,
    BackgroundColorRole = 8,
    BackgroundRole = 8,
    TextColorRole = 9,
    ForegroundRole = 9,
    CheckStateRole = 10,
    // Accessibility
    AccessibleTextRole = 11,
    AccessibleDescriptionRole = 12,
    // More general purpose
    SizeHintRole = 13,
    InitialSortOrderRole = 14,
    // Internal UiLib roles. Start worrying when public roles go that high.
    DisplayPropertyRole = 27,
    DecorationPropertyRole = 28,
    ToolTipPropertyRole = 29,
    StatusTipPropertyRole = 30,
    WhatsThisPropertyRole = 31,
    // Reserved
    UserRole = 32
};