pyside qcombobox hide item

pyside qcombobox hide item

from PySide2 import QtWidgets, QtCore
comboBox.setItemData(1,QtCore.QSize(0,0),QtCore.Qt.SizeHintRole)

我们也可以使用其它role去改变item的一些属性:参考链接:https://pyside.github.io/docs/pyside/PySide/QtCore/Qt.html

PySide.QtCore.Qt.ItemDataRole

Each item in the model has a set of data elements associated with it, each with its own role. The roles are used by the view to indicate to the model which type of data it needs. Custom models should return data in these types.

The general purpose roles (and the associated types) are:

ConstantDescription
Qt.DisplayRole The key data to be rendered in the form of text. ( PySide.QtCore.QString )
Qt.DecorationRole The data to be rendered as a decoration in the form of an icon. ( PySide.QtGui.QColor , PySide.QtGui.QIcon or PySide.QtGui.QPixmap )
Qt.EditRole The data in a form suitable for editing in an editor. ( PySide.QtCore.QString )
Qt.ToolTipRole The data displayed in the item’s tooltip. ( PySide.QtCore.QString )
Qt.StatusTipRole The data displayed in the status bar. ( PySide.QtCore.QString )
Qt.WhatsThisRole The data displayed for the item in “What’s This?” mode. ( PySide.QtCore.QString )
Qt.SizeHintRole The size hint for the item that will be supplied to views. ( PySide.QtCore.QSize )

Roles describing appearance and meta data (with associated types):

ConstantDescription
Qt.FontRole The font used for items rendered with the default delegate. ( PySide.QtGui.QFont )
Qt.TextAlignmentRole The alignment of the text for items rendered with the default delegate. ( Qt.AlignmentFlag )
Qt.BackgroundRole The background brush used for items rendered with the default delegate. ( PySide.QtGui.QBrush )
Qt.BackgroundColorRole This role is obsolete. Use BackgroundRole instead.
Qt.ForegroundRole The foreground brush (text color, typically) used for items rendered with the default delegate. ( PySide.QtGui.QBrush )
Qt.TextColorRole This role is obsolete. Use ForegroundRole instead.
Qt.CheckStateRole This role is used to obtain the checked state of an item. ( Qt.CheckState )
Qt.InitialSortOrderRole 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.

Accessibility roles (with associated types):

ConstantDescription
Qt.AccessibleTextRole The text to be used by accessibility extensions and plugins, such as screen readers. ( PySide.QtCore.QString )
Qt.AccessibleDescriptionRole A description of the item for accessibility purposes. ( PySide.QtCore.QString )

User roles:

ConstantDescription
Qt.UserRole The first role that can be used for application-specific purposes.

For user roles, it is up to the developer to decide which types to use and ensure that components use the correct types when accessing and setting data.

posted @ 2021-12-02 12:00  ibingshan  阅读(151)  评论(0编辑  收藏  举报