Subgroup: Field

Class: QgsFieldModel

class qgis.core.QgsFieldModel

Bases: PyQt5.QtCore.QAbstractItemModel

The QgsFieldModel class is a model to display the list of fields of a layer in widgets. If allowed, expressions might be added to the end of the model. It can be associated with a QgsMapLayerModel to dynamically display a layer and its fields.

New in version 2.3: Methods

allowEmptyFieldName Returns true if the model allows the empty field (“not set”) choice.
allowExpression Returns true if the model allows custom expressions to be created and displayed.
beginInsertColumns
beginInsertRows
beginMoveColumns
beginMoveRows
beginRemoveColumns
beginRemoveRows
beginResetModel
blockSignals
buddy
canDropMimeData
canFetchMore
changePersistentIndex
changePersistentIndexList
childEvent
children
columnCount
connectNotify
createIndex
customEvent
data
decodeData
deleteLater
disconnect
disconnectNotify
dropMimeData
dumpObjectInfo
dumpObjectTree
dynamicPropertyNames
encodeData
endInsertColumns
endInsertRows
endMoveColumns
endMoveRows
endRemoveColumns
endRemoveRows
endResetModel
event
eventFilter
fetchMore
findChild findChild(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> QObject
findChildren findChildren(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject]
flags
hasChildren
hasIndex
headerData
index
indexFromName Returns the index corresponding to a given fieldName.
inherits
insertColumn
insertColumns
insertRow
insertRows
installEventFilter
isField Returns true if a string represents a field reference, or false if it is an expression consisting of more than direct field reference.
isSignalConnected
isWidgetType
isWindowType
itemData
killTimer
layer Returns the layer associated with the model.
match
metaObject
mimeData
mimeTypes
moveColumn
moveColumns
moveRow
moveRows
moveToThread
objectName
parent
persistentIndexList
property
pyqtConfigure Each keyword argument is either the name of a Qt property or a Qt signal.
receivers
removeColumn
removeColumns
removeEventFilter
removeExpression Removes any custom expression from the model.
removeRow
removeRows
resetInternalData
revert
roleNames
rowCount
sender
senderSignalIndex
setAllowEmptyFieldName Sets whether an optional empty field (“not set”) option is present in the model.
setAllowExpression Sets whether custom expressions are accepted and displayed in the model.
setData
setExpression Sets a single expression to be added after the fields at the end of the model.
setHeaderData
setItemData
setLayer Set the layer from which fields are displayed.
setObjectName
setParent
setProperty
sibling
signalsBlocked
sort
span
startTimer
submit
supportedDragActions
supportedDropActions
thread
timerEvent
tr
updateModel Called when the model must be updated.

Attributes

ExpressionRole
ExpressionValidityRole
FieldIndexRole
FieldNameRole
FieldOriginRole
FieldTypeRole
HorizontalSortHint
IsEmptyRole
IsExpressionRole
NoLayoutChangeHint
VerticalSortHint
columnsAboutToBeInserted columnsAboutToBeInserted(self, QModelIndex, int, int) [signal]
columnsAboutToBeMoved columnsAboutToBeMoved(self, QModelIndex, int, int, QModelIndex, int) [signal]
columnsAboutToBeRemoved columnsAboutToBeRemoved(self, QModelIndex, int, int) [signal]
columnsInserted columnsInserted(self, QModelIndex, int, int) [signal]
columnsMoved columnsMoved(self, QModelIndex, int, int, QModelIndex, int) [signal]
columnsRemoved columnsRemoved(self, QModelIndex, int, int) [signal]
dataChanged dataChanged(self, QModelIndex, QModelIndex, Iterable[int] = []) [signal]
destroyed destroyed(self, QObject = None) [signal]
layoutAboutToBeChanged layoutAboutToBeChanged(self, object = QList<QPersistentModelIndex>(), QAbstractItemModel.LayoutChangeHint = QAbstractItemModel.NoLayoutChangeHint) [signal]
layoutChanged layoutChanged(self, Iterable[QPersistentModelIndex] = [], QAbstractItemModel.LayoutChangeHint = QAbstractItemModel.NoLayoutChangeHint) [signal]
modelAboutToBeReset modelAboutToBeReset(self) [signal]
modelReset modelReset(self) [signal]
objectNameChanged objectNameChanged(self, str) [signal]
rowsAboutToBeInserted rowsAboutToBeInserted(self, QModelIndex, int, int) [signal]
rowsAboutToBeMoved rowsAboutToBeMoved(self, QModelIndex, int, int, QModelIndex, int) [signal]
rowsAboutToBeRemoved rowsAboutToBeRemoved(self, QModelIndex, int, int) [signal]
rowsInserted rowsInserted(self, QModelIndex, int, int) [signal]
rowsMoved rowsMoved(self, QModelIndex, int, int, QModelIndex, int) [signal]
rowsRemoved rowsRemoved(self, QModelIndex, int, int) [signal]
staticMetaObject
ExpressionRole = 259
ExpressionValidityRole = 261
FieldIndexRole = 258
FieldNameRole = 257
FieldOriginRole = 263
class FieldRoles

Bases: int

FieldTypeRole = 262
IsEmptyRole = 264
IsExpressionRole = 260
allowEmptyFieldName(self) → bool

Returns true if the model allows the empty field (“not set”) choice.

New in version 3.0.

allowExpression(self) → bool

Returns true if the model allows custom expressions to be created and displayed.

beginInsertColumns()
beginInsertRows()
beginMoveColumns()
beginMoveRows()
beginRemoveColumns()
beginRemoveRows()
beginResetModel()
changePersistentIndex()
changePersistentIndexList()
childEvent()
columnCount(self, parent: QModelIndex) → int
connectNotify()
createIndex()
customEvent()
data(self, index: QModelIndex, role: int) → Any
decodeData()
disconnectNotify()
encodeData()
endInsertColumns()
endInsertRows()
endMoveColumns()
endMoveRows()
endRemoveColumns()
endRemoveRows()
endResetModel()
index(self, row: int, column: int, parent: QModelIndex = QModelIndex()) → QModelIndex
indexFromName(self, fieldName: str) → QModelIndex

Returns the index corresponding to a given fieldName.

isField(self, expression: str) → bool

Returns true if a string represents a field reference, or false if it is an expression consisting of more than direct field reference.

isSignalConnected()
layer(self) → QgsVectorLayer

Returns the layer associated with the model.

See also

setLayer()

parent(self, child: QModelIndex) → QModelIndex
persistentIndexList()
receivers()
removeExpression(self)

Removes any custom expression from the model.

See also

setExpression()

resetInternalData()
rowCount(self, parent: QModelIndex = QModelIndex()) → int
sender()
senderSignalIndex()
setAllowEmptyFieldName(self, allowEmpty: bool)

Sets whether an optional empty field (“not set”) option is present in the model.

New in version 3.0.

setAllowExpression(self, allowExpression: bool)

Sets whether custom expressions are accepted and displayed in the model.

See also

setExpression()

setExpression(self, expression: str)

Sets a single expression to be added after the fields at the end of the model.

setLayer(self, layer: QgsVectorLayer)

Set the layer from which fields are displayed.

See also

layer()

timerEvent()
updateModel(self)

Called when the model must be updated.