Class: QgsFieldsItem

A browser item which contains a collection of field items.

QgsFieldsItem contains internal logic to retrieve the fields and the corresponding vector layer instance from a connection URI, the schema and the table name.

Added in version 3.16.

Class Hierarchy

Inheritance diagram of qgis.core.QgsFieldsItem

Base classes

QgsDataItem

Base class for all items in the model.

QObject

Methods

canRenameFields

Returns True if the connection supports renaming fields.

connectionUri

Returns the connection URI

layer

Creates and returns a (possibly None) layer from the connection URI and schema/table information

schema

Returns the schema name

tableName

Returns the table name

tableProperty

Returns the (possibly None) properties of the table this fields belong to.

class qgis.core.QgsFieldsItem[source]

Bases: QgsDataItem

__init__(parent: QgsDataItem | None, path: str | None, connectionUri: str | None, providerKey: str | None, schema: str | None, tableName: str | None)

Constructor for QgsFieldsItem, with the specified parent item.

The path argument gives the item path in the browser tree. The path string can take any form, but QgsDataItem items pointing to different logical locations should always use a different item path. The connectionUri argument is the connection part of the layer URI that it is used internally to create a connection and retrieve fields information. The providerKey string can be used to specify the key for the QgsDataItemProvider that created this item. The schema and tableName are used to retrieve the layer and field information from the connectionUri.

Parameters:
  • parent (Optional[QgsDataItem])

  • path (Optional[str])

  • connectionUri (Optional[str])

  • providerKey (Optional[str])

  • schema (Optional[str])

  • tableName (Optional[str])

canRenameFields(self) bool[source]

Returns True if the connection supports renaming fields.

Added in version 3.28.

Return type:

bool

connectionUri(self) str[source]

Returns the connection URI

Return type:

str

layer(self) QgsVectorLayer | None[source]

Creates and returns a (possibly None) layer from the connection URI and schema/table information

Return type:

Optional[QgsVectorLayer]

schema(self) str[source]

Returns the schema name

Return type:

str

tableName(self) str[source]

Returns the table name

Return type:

str

tableProperty(self) QgsAbstractDatabaseProviderConnection.TableProperty | None[source]

Returns the (possibly None) properties of the table this fields belong to.

Added in version 3.16.

Return type:

Optional[QgsAbstractDatabaseProviderConnection.TableProperty]