Skip to content

PythonQt.QtGui.QItemDelegate · declarations 001

Back to PythonQt.QtGui.QItemDelegate

clipping instance-attribute

clipping: Any

Qt 5 reference:

clipping : bool

if the delegate should clip the paint events

This property will set the paint clip to the size of the item. The default value is on. It is useful for cases such as when images are larger than the size of the item.

This property was introduced in Qt 4.2.

Access functions:

bool hasClipping() const
void setClipping(bool clip)

Source: https://doc.qt.io/archives/qt-5.15/qitemdelegate.html#clipping

closeEditor

closeEditor(*args: Any, **kwargs: Any) -> Any

Native PythonQt.QtGui.QItemDelegate.closeEditor; argument details are not documented.

commitData

commitData(*args: Any, **kwargs: Any) -> Any

Native PythonQt.QtGui.QItemDelegate.commitData; argument details are not documented.

createEditor

createEditor(parent: Any, option: Any, index: Any) -> Any

X.createEditor(parent, option, index) -> PythonQt.QtGui.QWidget

Supplemental documentation: Qt 5 reference:

[override virtual] QWidget *QItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem \&option, const QModelIndex \&index) const

Reimplements: QAbstractItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem \&option, const QModelIndex \&index) const.

Returns the widget used to edit the item specified by index for editing. The parent widget and style option are used to control how the editor widget appears.

See also QAbstractItemDelegate::createEditor().

Upstream PySide2 reference signatures (binding differences may apply):

createEditor(self, parent: PySide2.QtWidgets.QWidget, option: PySide2.QtWidgets.QStyleOptionViewItem, index: PySide2.QtCore.QModelIndex) -> PySide2.QtWidgets.QWidget

Source: https://doc.qt.io/archives/qt-5.15/qitemdelegate.html#createEditor

decoration

decoration(option: Any, variant: Any) -> Any

X.decoration(option, variant) -> PythonQt.QtGui.QPixmap

Upstream PySide2 reference signatures (binding differences may apply):

decoration(self, option: PySide2.QtWidgets.QStyleOptionViewItem, variant: typing.Any) -> PySide2.QtGui.QPixmap

Source: https://doc.qt.io/archives/qt-5.15/qitemdelegate.html#decoration

destroyEditor

destroyEditor(editor: Any, index: Any) -> Any

X.destroyEditor(editor, index)

destroyed

destroyed(*args: Any, **kwargs: Any) -> Any

Native PythonQt.QtGui.QItemDelegate.destroyed; argument details are not documented.

doCheck

doCheck(option: Any, bounding: Any, variant: Any) -> Any

X.doCheck(option, bounding, variant) -> PythonQt.QtCore.QRect

Upstream PySide2 reference signatures (binding differences may apply):

doCheck(self, option: PySide2.QtWidgets.QStyleOptionViewItem, bounding: PySide2.QtCore.QRect, variant: typing.Any) -> PySide2.QtCore.QRect

Source: https://doc.qt.io/archives/qt-5.15/qitemdelegate.html#doCheck

drawBackground

drawBackground(painter: Any, option: Any, index: Any) -> None

X.drawBackground(painter, option, index)

Supplemental documentation: Qt 5 reference:

[protected] void QItemDelegate::drawBackground(QPainter *painter, const QStyleOptionViewItem \&option, const QModelIndex \&index) const

Renders the item background for the given index, using the given painter and style option.

This function was introduced in Qt 4.2.

Upstream PySide2 reference signatures (binding differences may apply):

drawBackground(self, painter: PySide2.QtGui.QPainter, option: PySide2.QtWidgets.QStyleOptionViewItem, index: PySide2.QtCore.QModelIndex) -> None

Source: https://doc.qt.io/archives/qt-5.15/qitemdelegate.html#drawBackground

drawCheck

drawCheck(painter: Any, option: Any, rect: Any, state: Any) -> None

X.drawCheck(painter, option, rect, state)

Supplemental documentation: Qt 5 reference:

[virtual protected] void QItemDelegate::drawCheck(QPainter *painter, const QStyleOptionViewItem \&option, const QRect \&rect, Qt::CheckState state) const

Renders a check indicator within the rectangle specified by rect, using the given painter and style option, using the given state.

Upstream PySide2 reference signatures (binding differences may apply):

drawCheck(self, painter: PySide2.QtGui.QPainter, option: PySide2.QtWidgets.QStyleOptionViewItem, rect: PySide2.QtCore.QRect, state: PySide2.QtCore.Qt.CheckState) -> None

Source: https://doc.qt.io/archives/qt-5.15/qitemdelegate.html#drawCheck

drawDecoration

drawDecoration(painter: Any, option: Any, rect: Any, pixmap: Any) -> None

X.drawDecoration(painter, option, rect, pixmap)

Supplemental documentation: Qt 5 reference:

[virtual protected] void QItemDelegate::drawDecoration(QPainter *painter, const QStyleOptionViewItem \&option, const QRect \&rect, const QPixmap \&pixmap) const

Renders the decoration pixmap within the rectangle specified by rect using the given painter and style option.

Upstream PySide2 reference signatures (binding differences may apply):

drawDecoration(self, painter: PySide2.QtGui.QPainter, option: PySide2.QtWidgets.QStyleOptionViewItem, rect: PySide2.QtCore.QRect, pixmap: PySide2.QtGui.QPixmap) -> None

Source: https://doc.qt.io/archives/qt-5.15/qitemdelegate.html#drawDecoration

drawDisplay

drawDisplay(painter: Any, option: Any, rect: Any, text: str) -> None

X.drawDisplay(painter, option, rect, text)

Supplemental documentation: Qt 5 reference:

[virtual protected] void QItemDelegate::drawDisplay(QPainter *painter, const QStyleOptionViewItem \&option, const QRect \&rect, const QString \&text) const

Renders the item view text within the rectangle specified by rect using the given painter and style option.

Upstream PySide2 reference signatures (binding differences may apply):

drawDisplay(self, painter: PySide2.QtGui.QPainter, option: PySide2.QtWidgets.QStyleOptionViewItem, rect: PySide2.QtCore.QRect, text: str) -> None

Source: https://doc.qt.io/archives/qt-5.15/qitemdelegate.html#drawDisplay

drawFocus

drawFocus(painter: Any, option: Any, rect: Any) -> None

X.drawFocus(painter, option, rect)

Supplemental documentation: Qt 5 reference:

[virtual protected] void QItemDelegate::drawFocus(QPainter *painter, const QStyleOptionViewItem \&option, const QRect \&rect) const

Renders the region within the rectangle specified by rect, indicating that it has the focus, using the given painter and style option.

Upstream PySide2 reference signatures (binding differences may apply):

drawFocus(self, painter: PySide2.QtGui.QPainter, option: PySide2.QtWidgets.QStyleOptionViewItem, rect: PySide2.QtCore.QRect) -> None

Source: https://doc.qt.io/archives/qt-5.15/qitemdelegate.html#drawFocus

editorEvent

editorEvent(event: Any, model: Any, option: Any, index: Any) -> bool

X.editorEvent(event, model, option, index) -> bool

Supplemental documentation: Qt 5 reference:

[override virtual protected] bool QItemDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem \&option, const QModelIndex \&index)

Reimplements: QAbstractItemDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem \&option, const QModelIndex \&index).

Upstream PySide2 reference signatures (binding differences may apply):

editorEvent(self, event: PySide2.QtCore.QEvent, model: PySide2.QtCore.QAbstractItemModel, option: PySide2.QtWidgets.QStyleOptionViewItem, index: PySide2.QtCore.QModelIndex) -> bool

Source: https://doc.qt.io/archives/qt-5.15/qitemdelegate.html#editorEvent

eventFilter

eventFilter(object: Any, event: Any) -> bool

X.eventFilter(object, event) -> bool

Supplemental documentation: Qt 5 reference:

[override virtual protected] bool QItemDelegate::eventFilter(QObject *editor, QEvent *event)

Reimplements: QObject::eventFilter(QObject *watched, QEvent *event).

Returns true if the given editor is a valid QWidget and the given event is handled; otherwise returns false. The following key press events are handled by default:

  • Tab
  • Backtab
  • Enter
  • Return
  • Esc

In the case of Tab, Backtab, Enter and Return key press events, the editor's data is committed to the model and the editor is closed. If the event is a Tab key press the view will open an editor on the next item in the view. Likewise, if the event is a Backtab key press the view will open an editor on the previous item in the view.

If the event is a Esc key press event, the editor is closed without committing its data.

See also commitData() and closeEditor().

Upstream PySide2 reference signatures (binding differences may apply):

eventFilter(self, object: PySide2.QtCore.QObject, event: PySide2.QtCore.QEvent) -> bool

Source: https://doc.qt.io/archives/qt-5.15/qitemdelegate.html#eventFilter

hasClipping

hasClipping() -> bool

X.hasClipping() -> bool

Upstream PySide2 reference signatures (binding differences may apply):

hasClipping(self) -> bool

Source: https://doc.qt.io/archives/qt-5.15/qitemdelegate.html#hasClipping

helpEvent

helpEvent(event: Any, view: Any, option: Any, index: Any) -> bool

X.helpEvent(event, view, option, index) -> bool

itemEditorFactory

itemEditorFactory() -> Any

X.itemEditorFactory() -> PythonQt.QtGui.QItemEditorFactory

Supplemental documentation: Qt 5 reference:

QItemEditorFactory *QItemDelegate::itemEditorFactory() const

Returns the editor factory used by the item delegate. If no editor factory is set, the function will return null.

See also setItemEditorFactory().

Upstream PySide2 reference signatures (binding differences may apply):

itemEditorFactory(self) -> PySide2.QtWidgets.QItemEditorFactory

Source: https://doc.qt.io/archives/qt-5.15/qitemdelegate.html#itemEditorFactory

objectNameChanged

objectNameChanged(*args: Any, **kwargs: Any) -> Any

Native PythonQt.QtGui.QItemDelegate.objectNameChanged; argument details are not documented.

paint

paint(painter: Any, option: Any, index: Any) -> None

X.paint(painter, option, index)

Supplemental documentation: Qt 5 reference:

[override virtual] void QItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem \&option, const QModelIndex \&index) const

Reimplements: QAbstractItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem \&option, const QModelIndex \&index) const.

Renders the delegate using the given painter and style option for the item specified by index.

When reimplementing this function in a subclass, you should update the area held by the option's rect variable, using the option's state variable to determine the state of the item to be displayed, and adjust the way it is painted accordingly.

For example, a selected item may need to be displayed differently to unselected items, as shown in the following code:

    if (option.state & QStyle::State_Selected)
        painter->fillRect(option.rect, option.palette.highlight());

    const int size = qMin(option.rect.width(), option.rect.height());
    const int brightness = index.model()->data(index, Qt::DisplayRole).toInt();
    const double radius = (size / 2.0) - (brightness / 255.0 * size / 2.0);
    if (qFuzzyIsNull(radius))
        return;

    painter->save();
    painter->setRenderHint(QPainter::Antialiasing, true);
    painter->setPen(Qt::NoPen);
    if (option.state & QStyle::State_Selected)
        painter->setBrush(option.palette.highlightedText());
    else
    ...

After painting, you should ensure that the painter is returned to its the state it was supplied in when this function was called. For example, it may be useful to call QPainter::save() before painting and QPainter::restore() afterwards.

See also QStyle::State.

Upstream PySide2 reference signatures (binding differences may apply):

paint(self, painter: PySide2.QtGui.QPainter, option: PySide2.QtWidgets.QStyleOptionViewItem, index: PySide2.QtCore.QModelIndex) -> None

Source: https://doc.qt.io/archives/qt-5.15/qitemdelegate.html#paint

paintingRoles

paintingRoles() -> tuple

X.paintingRoles() -> tuple

rect

rect(option: Any, index: Any, role: int) -> Any

X.rect(option, index, role) -> PythonQt.QtCore.QRect

Upstream PySide2 reference signatures (binding differences may apply):

rect(self, option: PySide2.QtWidgets.QStyleOptionViewItem, index: PySide2.QtCore.QModelIndex, role: int) -> PySide2.QtCore.QRect

Source: https://doc.qt.io/archives/qt-5.15/qitemdelegate.html#rect

setClipping

setClipping(clip: bool) -> None

X.setClipping(clip)

Upstream PySide2 reference signatures (binding differences may apply):

setClipping(self, clip: bool) -> None

Source: https://doc.qt.io/archives/qt-5.15/qitemdelegate.html#setClipping

setEditorData

setEditorData(editor: Any, index: Any) -> None

X.setEditorData(editor, index)

Supplemental documentation: Qt 5 reference:

[override virtual] void QItemDelegate::setEditorData(QWidget *editor, const QModelIndex \&index) const

Reimplements: QAbstractItemDelegate::setEditorData(QWidget *editor, const QModelIndex \&index) const.

Sets the data to be displayed and edited by the editor from the data model item specified by the model index.

The default implementation stores the data in the editor widget's user property.

See also QMetaProperty::isUser().

Upstream PySide2 reference signatures (binding differences may apply):

setEditorData(self, editor: PySide2.QtWidgets.QWidget, index: PySide2.QtCore.QModelIndex) -> None

Source: https://doc.qt.io/archives/qt-5.15/qitemdelegate.html#setEditorData

setItemEditorFactory

setItemEditorFactory(factory: Any) -> None

X.setItemEditorFactory(factory)

Supplemental documentation: Qt 5 reference:

void QItemDelegate::setItemEditorFactory(QItemEditorFactory *factory)

Sets the editor factory to be used by the item delegate to be the factory specified. If no editor factory is set, the item delegate will use the default editor factory.

See also itemEditorFactory().

Upstream PySide2 reference signatures (binding differences may apply):

setItemEditorFactory(self, factory: PySide2.QtWidgets.QItemEditorFactory) -> None

Source: https://doc.qt.io/archives/qt-5.15/qitemdelegate.html#setItemEditorFactory

setModelData

setModelData(editor: Any, model: Any, index: Any) -> None

X.setModelData(editor, model, index)

Supplemental documentation: Qt 5 reference:

[override virtual] void QItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex \&index) const

Reimplements: QAbstractItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex \&index) const.

Gets data from the editor widget and stores it in the specified model at the item index.

The default implementation gets the value to be stored in the data model from the editor widget's user property.

See also QMetaProperty::isUser().

Upstream PySide2 reference signatures (binding differences may apply):

setModelData(self, editor: PySide2.QtWidgets.QWidget, model: PySide2.QtCore.QAbstractItemModel, index: PySide2.QtCore.QModelIndex) -> None

Source: https://doc.qt.io/archives/qt-5.15/qitemdelegate.html#setModelData

setOptions

setOptions(index: Any, option: Any) -> Any

X.setOptions(index, option) -> PythonQt.QtGui.QStyleOptionViewItem

Upstream PySide2 reference signatures (binding differences may apply):

setOptions(self, index: PySide2.QtCore.QModelIndex, option: PySide2.QtWidgets.QStyleOptionViewItem) -> PySide2.QtWidgets.QStyleOptionViewItem

Source: https://doc.qt.io/archives/qt-5.15/qitemdelegate.html#setOptions

sizeHint

sizeHint(option: Any, index: Any) -> Any

X.sizeHint(option, index) -> PythonQt.QtCore.QSize

Supplemental documentation: Qt 5 reference:

[override virtual] QSize QItemDelegate::sizeHint(const QStyleOptionViewItem \&option, const QModelIndex \&index) const

Reimplements: QAbstractItemDelegate::sizeHint(const QStyleOptionViewItem \&option, const QModelIndex \&index) const.

Returns the size needed by the delegate to display the item specified by index, taking into account the style information provided by option.

When reimplementing this function, note that in case of text items, QItemDelegate adds a margin (i.e. 2 * QStyle::PM_FocusFrameHMargin) to the length of the text.

Upstream PySide2 reference signatures (binding differences may apply):

sizeHint(self, option: PySide2.QtWidgets.QStyleOptionViewItem, index: PySide2.QtCore.QModelIndex) -> PySide2.QtCore.QSize

Source: https://doc.qt.io/archives/qt-5.15/qitemdelegate.html#sizeHint

sizeHintChanged

sizeHintChanged(*args: Any, **kwargs: Any) -> Any

Native PythonQt.QtGui.QItemDelegate.sizeHintChanged; argument details are not documented.

textRectangle

textRectangle(painter: Any, rect: Any, font: Any, text: str) -> Any

X.textRectangle(painter, rect, font, text) -> PythonQt.QtCore.QRect

Upstream PySide2 reference signatures (binding differences may apply):

textRectangle(self, painter: PySide2.QtGui.QPainter, rect: PySide2.QtCore.QRect, font: PySide2.QtGui.QFont, text: str) -> PySide2.QtCore.QRect

Source: https://doc.qt.io/archives/qt-5.15/qitemdelegate.html#textRectangle

updateEditorGeometry

updateEditorGeometry(editor: Any, option: Any, index: Any) -> None

X.updateEditorGeometry(editor, option, index)

Supplemental documentation: Qt 5 reference:

[override virtual] void QItemDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem \&option, const QModelIndex \&index) const

Reimplements: QAbstractItemDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem \&option, const QModelIndex \&index) const.

Updates the editor for the item specified by index according to the style option given.

Upstream PySide2 reference signatures (binding differences may apply):

updateEditorGeometry(self, editor: PySide2.QtWidgets.QWidget, option: PySide2.QtWidgets.QStyleOptionViewItem, index: PySide2.QtCore.QModelIndex) -> None

Source: https://doc.qt.io/archives/qt-5.15/qitemdelegate.html#updateEditorGeometry