Mix-in Classes

Mix-in classes for Qt types.

class objettoqt.mixins.OQObjectMixin(*args, **kwargs)

Mix-in class for QObject types.

Observes actions sent from an instance of objetto.bases.BaseObject.

>>> from Qt import QtCore
>>> from objettoqt.mixins import OQObjectMixin

>>> class MixedQObject(OQObjectMixin, QtCore.QObject):
...     pass
...
Raises

TypeError – Not mixed in with a QObject class.

objChanged

signal

Emitted when the source objetto.bases.BaseObject changes.

Parameters
actionReceived

signal

Emitted when an action is received.

Parameters
QBase

read-only class attribute

Minimum Qt base requirement.

Type

type[QObject]

OBase

read-only class attribute

Minimum objetto object base requirement.

Type

type[objetto.bases.BaseObject]

_onDestroyed()

virtual method

Called after this has been destroyed.

_onObjChanged(obj, old_obj, phase)

virtual method

Called when the source objetto.bases.BaseObject changes.

This method is called before the objettoqt.mixins.OQObjectMixin.objChanged signal gets emitted.

Parameters
_onActionReceived(action, phase)

virtual method

Called when an action is received.

This method is called before the objettoqt.mixins.OQObjectMixin.actionReceived signal gets emitted.

Parameters
isDestroyed()

final method

Get whether this has been destroyed or not.

Returns

True if destroyed.

Return type

bool

obj()

final method

Get the object being observed.

Returns

Object being observed (or None).

Return type

objetto.bases.BaseObject or None

setObj(obj)

final method

Set the object to observe.

Parameters

obj (objetto.bases.BaseObject or None) – Object to observe (or None).

objToken()

final method

Get the action observer token.

Returns

Action observer token.

Return type

objetto.observers.ActionObserverToken

class objettoqt.mixins.OQWidgetMixin(*args, **kwargs)

Mix-in class for QWidget types.

Observes actions sent from an instance of objetto.bases.BaseObject.

Inherits from:
>>> from Qt import QtCore
>>> from objettoqt.mixins import OQWidgetMixin

>>> class MixedQAbstractItemModel(OQWidgetMixin, QtWidgets.QWidget):
...     pass
...
Raises

TypeError – Not mixed in with a QWidget class.

QBase

read-only class attribute

Minimum Qt base requirement.

Type

type[QWidget]

class objettoqt.mixins.OQAbstractItemModelMixin(*args, **kwargs)

Mix-in class for QAbstractItemModel types.

Observes actions sent from an instance of objetto.bases.BaseObject.

Inherits from:
>>> from Qt import QtCore
>>> from objettoqt.mixins import OQAbstractItemModelMixin

>>> class MixedQAbstractItemModel(
...     OQAbstractItemModelMixin, QtCore.QAbstractItemModel
... ):
...     pass
...
Raises

TypeError – Not mixed in with a QAbstractItemModel class.

QBase

read-only class attribute

Minimum Qt base requirement.

Type

type[QAbstractItemModel]

class objettoqt.mixins.OQAbstractItemViewMixin(*args, **kwargs)

Mix-in class for QAbstractItemView types (for lists).

Observes actions sent from an instance of objetto.bases.BaseObject.

Inherits from:
>>> from Qt import QtWidgets
>>> from objettoqt.mixins import OQAbstractItemViewMixin

>>> class MixedQAbstractItemView(
...     OQAbstractItemViewMixin, QtWidgets.QAbstractItemView
... ):
...     pass
...
Raises

TypeError – Not mixed in with a QAbstractItemView class.

QBase

read-only class attribute

Minimum Qt base requirement.

Type

type[QAbstractItemView]

class objettoqt.mixins.OQListViewMixin(*args, **kwargs)

Mix-in class for QAbstractItemView types.

Observes actions sent from an instance of objetto.bases.BaseObject.

Inherits from:
>>> from Qt import QtWidgets
>>> from objettoqt.mixins import OQListViewMixin

>>> class MixedQListView(OQListViewMixin, QtWidgets.QListView):
...     pass
...
>>> class MixedQTreeListView(OQListViewMixin, QtWidgets.QTreeView):
...     pass
...
Raises

TypeError – Not mixed in with a QAbstractItemView class.

setAcceptDrops(accept_drop)

Set whether to accept drops.

Parameters

accept_drop (bool) – True to accept.

setDragEnabled(drag_enabled)

Set whether to enable drag.

Parameters

drag_enabled (bool) – True to enable.

setSelectionMode(mode)

Set selection mode.

Allowed selection modes are:
  • QtWidgets.QAbstractItemView.SingleSelection

  • QtWidgets.QAbstractItemView.ContiguousSelection

  • QtWidgets.QAbstractItemView.NoSelection

Parameters

mode (SelectionMode) – Supported selection mode.

Raises

ValueError – Unsupported selection mode provided.

setSelectionBehavior(behavior)

Set selection behavior.

Allowed selection behaviors are:
  • QtWidgets.QAbstractItemView.SelectRows

Parameters

behavior (SelectionBehavior) – Selection behavior.

Raises

ValueError – Unsupported selection behavior provided.

setDragDropMode(mode)

Set drag and drop mode.

Allowed drag and drop modes are:
  • QtWidgets.QAbstractItemView.NoDragDrop

  • QtWidgets.QAbstractItemView.DragOnly

  • QtWidgets.QAbstractItemView.DropOnly

  • QtWidgets.QAbstractItemView.DragDrop

Parameters

mode (DragDropMode) – Drag and drop mode.

Raises

ValueError – Unsupported drag and drop mode provided.

setDragDropOverwriteMode(overwrite)

Set drag and drop overwrite mode.

Parameters

overwrite (bool) – Only False is allowed.

Raises

ValueError – Unsupported drag and drop overwwrite mode provided.

setDefaultDropAction(action)

Set default drop action.

Allowed default drop actions are:
  • QtCore.Qt.DropAction.IgnoreAction

  • QtCore.Qt.DropAction.CopyAction

  • QtCore.Qt.DropAction.MoveAction

  • QtCore.Qt.DropAction.ActionMask

Parameters

action (DropAction) – Drop action.

select(selection, mode, current=None)

Select and set current.

Parameters
deleteSelected()

slot

Delete currently selected.

clearCurrent()

slot

Clear current.

clearSelection()

slot

Clear selection and current.

showCustomContextMenu(position)

virtual method

Show custom context menu.

Parameters

position (QPoint) – Position.

Returns

True if shown.

Return type

bool