Skip to content

PythonQt.QtGui.QDataWidgetMapper · declarations 001

Back to PythonQt.QtGui.QDataWidgetMapper

AutoSubmit instance-attribute

AutoSubmit: Any

ManualSubmit instance-attribute

ManualSubmit: Any

SubmitPolicy instance-attribute

SubmitPolicy: type

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.int(). For floating point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by '+' or '-' and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal.

int('0b100', base=0) 4

addMapping

addMapping(widget: Any, section: int, propertyName: Any) -> None

X.addMapping(widget, section, propertyName)

Supplemental documentation: Qt 5 reference:

void QDataWidgetMapper::addMapping(QWidget *widget, int section)

Adds a mapping between a widget and a section from the model. The section is a column in the model if the orientation is horizontal (the default), otherwise a row.

For the following example, we assume a model myModel that has two columns: the first one contains the names of people in a group, and the second column contains their ages. The first column is mapped to the QLineEdit nameLineEdit, and the second is mapped to the QSpinBox ageSpinBox:

QDataWidgetMapper *mapper = new QDataWidgetMapper;
mapper->setModel(myModel);
mapper->addMapping(nameLineEdit, 0);
mapper->addMapping(ageSpinBox, 1);

Notes:

  • If the widget is already mapped to a section, the old mapping will be replaced by the new one.
  • Only one-to-one mappings between sections and widgets are allowed. It is not possible to map a single section to multiple widgets, or to map a single widget to multiple sections.

See also removeMapping(), mappedSection(), and clearMapping().

void QDataWidgetMapper::addMapping(QWidget *widget, int section, const QByteArray \&propertyName)

Essentially the same as addMapping(), but adds the possibility to specify the property to use specifying propertyName.

This function was introduced in Qt 4.3.

See also addMapping().

Upstream PySide2 reference signatures (binding differences may apply):

addMapping(self, widget: PySide2.QtWidgets.QWidget, section: int) -> None
addMapping(self, widget: PySide2.QtWidgets.QWidget, section: int, propertyName: PySide2.QtCore.QByteArray) -> None

Source: https://doc.qt.io/archives/qt-5.15/qdatawidgetmapper.html#addMapping

clearMapping

clearMapping() -> None

X.clearMapping()

Supplemental documentation: Qt 5 reference:

void QDataWidgetMapper::clearMapping()

Clears all mappings.

See also addMapping() and removeMapping().

Upstream PySide2 reference signatures (binding differences may apply):

clearMapping(self) -> None

Source: https://doc.qt.io/archives/qt-5.15/qdatawidgetmapper.html#clearMapping

currentIndex instance-attribute

currentIndex: int

Qt 5 reference:

currentIndex : int

This property holds the current row or column

The widgets are populated with with data from the row at index if the orientation is horizontal (the default), otherwise with data from the column at index.

Access functions:

int currentIndex() const
virtual void setCurrentIndex(int index)

Notifier signal:

void currentIndexChanged(int index)

See also setCurrentModelIndex(), toFirst(), toNext(), toPrevious(), and toLast().

Source: https://doc.qt.io/archives/qt-5.15/qdatawidgetmapper.html#currentIndex

currentIndexChanged

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

Native PythonQt.QtGui.QDataWidgetMapper.currentIndexChanged; argument details are not documented.

Supplemental documentation: Qt 5 reference:

[signal] void QDataWidgetMapper::currentIndexChanged(int index)

This signal is emitted after the current index has changed and all widgets were populated with new data. index is the new current index.

Note: Notifier signal for property currentIndex.

See also currentIndex() and setCurrentIndex().

Source: https://doc.qt.io/archives/qt-5.15/qdatawidgetmapper.html#currentIndexChanged

destroyed

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

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

itemDelegate

itemDelegate() -> Any

X.itemDelegate() -> PythonQt.QtGui.QAbstractItemDelegate

Supplemental documentation: Qt 5 reference:

QAbstractItemDelegate *QDataWidgetMapper::itemDelegate() const

Returns the current item delegate.

See also setItemDelegate().

Upstream PySide2 reference signatures (binding differences may apply):

itemDelegate(self) -> PySide2.QtWidgets.QAbstractItemDelegate

Source: https://doc.qt.io/archives/qt-5.15/qdatawidgetmapper.html#itemDelegate

mappedPropertyName

mappedPropertyName(widget: Any) -> Any

X.mappedPropertyName(widget) -> PythonQt.QtCore.QByteArray

Supplemental documentation: Qt 5 reference:

QByteArray QDataWidgetMapper::mappedPropertyName(QWidget *widget) const

Returns the name of the property that is used when mapping data to the given widget.

This function was introduced in Qt 4.3.

See also mappedSection(), addMapping(), and removeMapping().

Upstream PySide2 reference signatures (binding differences may apply):

mappedPropertyName(self, widget: PySide2.QtWidgets.QWidget) -> PySide2.QtCore.QByteArray

Source: https://doc.qt.io/archives/qt-5.15/qdatawidgetmapper.html#mappedPropertyName

mappedSection

mappedSection(widget: Any) -> int

X.mappedSection(widget) -> int

Supplemental documentation: Qt 5 reference:

int QDataWidgetMapper::mappedSection(QWidget *widget) const

Returns the section the widget is mapped to or -1 if the widget is not mapped.

See also addMapping() and removeMapping().

Upstream PySide2 reference signatures (binding differences may apply):

mappedSection(self, widget: PySide2.QtWidgets.QWidget) -> int

Source: https://doc.qt.io/archives/qt-5.15/qdatawidgetmapper.html#mappedSection

mappedWidgetAt

mappedWidgetAt(section: int) -> Any

X.mappedWidgetAt(section) -> PythonQt.QtGui.QWidget

Supplemental documentation: Qt 5 reference:

QWidget *QDataWidgetMapper::mappedWidgetAt(int section) const

Returns the widget that is mapped at section, or 0 if no widget is mapped at that section.

See also addMapping() and removeMapping().

Upstream PySide2 reference signatures (binding differences may apply):

mappedWidgetAt(self, section: int) -> PySide2.QtWidgets.QWidget

Source: https://doc.qt.io/archives/qt-5.15/qdatawidgetmapper.html#mappedWidgetAt

model

model() -> Any

X.model() -> PythonQt.QtCore.QAbstractItemModel

Supplemental documentation: Qt 5 reference:

QAbstractItemModel *QDataWidgetMapper::model() const

Returns the current model.

See also setModel().

Upstream PySide2 reference signatures (binding differences may apply):

model(self) -> PySide2.QtCore.QAbstractItemModel

Source: https://doc.qt.io/archives/qt-5.15/qdatawidgetmapper.html#model

objectNameChanged

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

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

orientation instance-attribute

orientation: Any

Qt 5 reference:

orientation : Qt::Orientation

This property holds the orientation of the model

If the orientation is Qt::Horizontal (the default), a widget is mapped to a column of a data model. The widget will be populated with the model's data from its mapped column and the row that currentIndex() points at.

Use Qt::Horizontal for tabular data that looks like this:

1 Qt Norway Oslo
2 Qt Australia Brisbane
3 Qt USA Silicon Valley
4 Qt China Beijing
5 Qt Germany Berlin

If the orientation is set to Qt::Vertical, a widget is mapped to a row. Calling setCurrentIndex() will change the current column. The widget will be populates with the model's data from its mapped row and the column that currentIndex() points at.

Use Qt::Vertical for tabular data that looks like this:

1 2 3 4 5
Qt Norway Qt Australia Qt USA Qt China Qt Germany
Oslo Brisbane Silicon Valley Beijing Berlin

Changing the orientation clears all existing mappings.

Access functions:

Qt::Orientation orientation() const
void setOrientation(Qt::Orientation aOrientation)

Source: https://doc.qt.io/archives/qt-5.15/qdatawidgetmapper.html#orientation

removeMapping

removeMapping(widget: Any) -> None

X.removeMapping(widget)

Supplemental documentation: Qt 5 reference:

void QDataWidgetMapper::removeMapping(QWidget *widget)

Removes the mapping for the given widget.

See also addMapping() and clearMapping().

Upstream PySide2 reference signatures (binding differences may apply):

removeMapping(self, widget: PySide2.QtWidgets.QWidget) -> None

Source: https://doc.qt.io/archives/qt-5.15/qdatawidgetmapper.html#removeMapping

revert

revert() -> None

X.revert()

Supplemental documentation: Qt 5 reference:

[slot] void QDataWidgetMapper::revert()

Repopulates all widgets with the current data of the model. All unsubmitted changes will be lost.

See also submit() and setSubmitPolicy().

Upstream PySide2 reference signatures (binding differences may apply):

revert(self) -> None

Source: https://doc.qt.io/archives/qt-5.15/qdatawidgetmapper.html#revert

rootIndex

rootIndex() -> Any

X.rootIndex() -> PythonQt.QtCore.QModelIndex

Supplemental documentation: Qt 5 reference:

QModelIndex QDataWidgetMapper::rootIndex() const

Returns the current root index.

See also setRootIndex().

Upstream PySide2 reference signatures (binding differences may apply):

rootIndex(self) -> PySide2.QtCore.QModelIndex

Source: https://doc.qt.io/archives/qt-5.15/qdatawidgetmapper.html#rootIndex

setCurrentIndex

setCurrentIndex(index: int) -> None

X.setCurrentIndex(index)

Upstream PySide2 reference signatures (binding differences may apply):

setCurrentIndex(self, index: int) -> None

Source: https://doc.qt.io/archives/qt-5.15/qdatawidgetmapper.html#setCurrentIndex

setCurrentModelIndex

setCurrentModelIndex(index: Any) -> None

X.setCurrentModelIndex(index)

Supplemental documentation: Qt 5 reference:

[slot] void QDataWidgetMapper::setCurrentModelIndex(const QModelIndex \&index)

Sets the current index to the row of the index if the orientation is horizontal (the default), otherwise to the column of the index.

Calls setCurrentIndex() internally. This convenience slot can be connected to the signal currentRowChanged() or currentColumnChanged() of another view's selection model.

The following example illustrates how to update all widgets with new data whenever the selection of a QTableView named myTableView changes:

QDataWidgetMapper *mapper = new QDataWidgetMapper;
connect(myTableView->selectionModel(), &QItemSelectionModel::currentRowChanged,
        mapper, &QDataWidgetMapper::setCurrentModelIndex);

See also currentIndex().

Upstream PySide2 reference signatures (binding differences may apply):

setCurrentModelIndex(self, index: PySide2.QtCore.QModelIndex) -> None

Source: https://doc.qt.io/archives/qt-5.15/qdatawidgetmapper.html#setCurrentModelIndex

setItemDelegate

setItemDelegate(delegate: Any) -> None

X.setItemDelegate(delegate)

Supplemental documentation: Qt 5 reference:

void QDataWidgetMapper::setItemDelegate(QAbstractItemDelegate *delegate)

Sets the item delegate to delegate. The delegate will be used to write data from the model into the widget and from the widget to the model, using QAbstractItemDelegate::setEditorData() and QAbstractItemDelegate::setModelData().

The delegate also decides when to apply data and when to change the editor, using QAbstractItemDelegate::commitData() and QAbstractItemDelegate::closeEditor().

Warning: You should not share the same instance of a delegate between widget mappers or views. Doing so can cause incorrect or unintuitive editing behavior since each view connected to a given delegate may receive the closeEditor() signal, and attempt to access, modify or close an editor that has already been closed.

See also itemDelegate().

Upstream PySide2 reference signatures (binding differences may apply):

setItemDelegate(self, delegate: PySide2.QtWidgets.QAbstractItemDelegate) -> None

Source: https://doc.qt.io/archives/qt-5.15/qdatawidgetmapper.html#setItemDelegate

setModel

setModel(model: Any) -> None

X.setModel(model)

Supplemental documentation: Qt 5 reference:

void QDataWidgetMapper::setModel(QAbstractItemModel *model)

Sets the current model to model. If another model was set, all mappings to that old model are cleared.

See also model().

Upstream PySide2 reference signatures (binding differences may apply):

setModel(self, model: PySide2.QtCore.QAbstractItemModel) -> None

Source: https://doc.qt.io/archives/qt-5.15/qdatawidgetmapper.html#setModel

setOrientation

setOrientation(aOrientation: Any) -> None

X.setOrientation(aOrientation)

Upstream PySide2 reference signatures (binding differences may apply):

setOrientation(self, aOrientation: PySide2.QtCore.Qt.Orientation) -> None

Source: https://doc.qt.io/archives/qt-5.15/qdatawidgetmapper.html#setOrientation

setRootIndex

setRootIndex(index: Any) -> None

X.setRootIndex(index)

Supplemental documentation: Qt 5 reference:

void QDataWidgetMapper::setRootIndex(const QModelIndex \&index)

Sets the root item to index. This can be used to display a branch of a tree. Pass an invalid model index to display the top-most branch.

See also rootIndex().

Upstream PySide2 reference signatures (binding differences may apply):

setRootIndex(self, index: PySide2.QtCore.QModelIndex) -> None

Source: https://doc.qt.io/archives/qt-5.15/qdatawidgetmapper.html#setRootIndex

setSubmitPolicy

setSubmitPolicy(policy: Any) -> None

X.setSubmitPolicy(policy)

Upstream PySide2 reference signatures (binding differences may apply):

setSubmitPolicy(self, policy: PySide2.QtWidgets.QDataWidgetMapper.SubmitPolicy) -> None

Source: https://doc.qt.io/archives/qt-5.15/qdatawidgetmapper.html#setSubmitPolicy

submit

submit() -> bool

X.submit() -> bool

Supplemental documentation: Qt 5 reference:

[slot] bool QDataWidgetMapper::submit()

Submits all changes from the mapped widgets to the model.

For every mapped section, the item delegate reads the current value from the widget and sets it in the model. Finally, the model's submit() method is invoked.

Returns true if all the values were submitted, otherwise false.

Note: For database models, QSqlQueryModel::lastError() can be used to retrieve the last error.

See also revert() and setSubmitPolicy().

Upstream PySide2 reference signatures (binding differences may apply):

submit(self) -> bool

Source: https://doc.qt.io/archives/qt-5.15/qdatawidgetmapper.html#submit

submitPolicy instance-attribute

submitPolicy: Any

Qt 5 reference:

submitPolicy : SubmitPolicy

This property holds the current submit policy

Changing the current submit policy will revert all widgets to the current data from the model.

Access functions:

QDataWidgetMapper::SubmitPolicy submitPolicy() const
void setSubmitPolicy(QDataWidgetMapper::SubmitPolicy policy)

Source: https://doc.qt.io/archives/qt-5.15/qdatawidgetmapper.html#submitPolicy

toFirst

toFirst() -> None

X.toFirst()

Supplemental documentation: Qt 5 reference:

[slot] void QDataWidgetMapper::toFirst()

Populates the widgets with data from the first row of the model if the orientation is horizontal (the default), otherwise with data from the first column.

This is equivalent to calling setCurrentIndex(0).

See also toLast() and setCurrentIndex().

Upstream PySide2 reference signatures (binding differences may apply):

toFirst(self) -> None

Source: https://doc.qt.io/archives/qt-5.15/qdatawidgetmapper.html#toFirst

toLast

toLast() -> None

X.toLast()

Supplemental documentation: Qt 5 reference:

[slot] void QDataWidgetMapper::toLast()

Populates the widgets with data from the last row of the model if the orientation is horizontal (the default), otherwise with data from the last column.

Calls setCurrentIndex() internally.

See also toFirst() and setCurrentIndex().

Upstream PySide2 reference signatures (binding differences may apply):

toLast(self) -> None

Source: https://doc.qt.io/archives/qt-5.15/qdatawidgetmapper.html#toLast

toNext

toNext() -> None

X.toNext()

Supplemental documentation: Qt 5 reference:

[slot] void QDataWidgetMapper::toNext()

Populates the widgets with data from the next row of the model if the orientation is horizontal (the default), otherwise with data from the next column.

Calls setCurrentIndex() internally. Does nothing if there is no next row in the model.

See also toPrevious() and setCurrentIndex().

Upstream PySide2 reference signatures (binding differences may apply):

toNext(self) -> None

Source: https://doc.qt.io/archives/qt-5.15/qdatawidgetmapper.html#toNext

toPrevious

toPrevious() -> None

X.toPrevious()

Supplemental documentation: Qt 5 reference:

[slot] void QDataWidgetMapper::toPrevious()

Populates the widgets with data from the previous row of the model if the orientation is horizontal (the default), otherwise with data from the previous column.

Calls setCurrentIndex() internally. Does nothing if there is no previous row in the model.

See also toNext() and setCurrentIndex().

Upstream PySide2 reference signatures (binding differences may apply):

toPrevious(self) -> None

Source: https://doc.qt.io/archives/qt-5.15/qdatawidgetmapper.html#toPrevious