Class: QgsDatabaseTableComboBox¶
A combobox which displays the list of tables for a specific database connection.
Warning
The provider must support the connection API methods in its QgsProviderMetadata implementation
in order for the combobox to work correctly.
Added in version 3.14.
Class Hierarchy¶
Base classes¶
- class qgis.gui.QgsDatabaseTableComboBox[source]¶
Bases:
QWidget- __init__(provider: str | None, connection: str | None, schema: str | None = '', parent: QWidget | None = None)
Constructor for QgsDatabaseTableComboBox, for the specified
providerandconnection.The optional
schemaargument can be used to restrict the listed tables to a specific schema.Warning
The provider must support the connection API methods in its
QgsProviderMetadataimplementation in order for the model to work correctly.- Parameters:
provider (Optional[str])
connection (Optional[str])
schema (Optional[str] = '')
parent (Optional[QWidget] = None)
- __init__(connection: QgsAbstractDatabaseProviderConnection | None, schema: str | None = '', parent: QWidget | None = None)
Constructor for QgsDatabaseTableComboBox, for the specified
connection.The optional
schemaargument can be used to restrict the listed tables to a specific schema.Ownership of
connectionis transferred to the combobox.- Parameters:
connection (Optional[QgsAbstractDatabaseProviderConnection])
schema (Optional[str] = '')
parent (Optional[QWidget] = None)
- allowEmptyTable(self) bool[source]¶
Returns
Trueif the combobox allows the empty table (“not set”) choice.See also
- Return type:
bool
- comboBox(self) QComboBox | None[source]¶
Returns the combobox portion of the widget.
- Return type:
Optional[QComboBox]
- currentSchema(self) str[source]¶
Returns the schema of the current table selected in the combo box.
- Return type:
str
- currentTable(self) str[source]¶
Returns the name of the current table selected in the combo box.
- Return type:
str
- setAllowEmptyTable(self, allowEmpty: bool)[source]¶
Sets whether an optional empty table (“not set”) option is present in the combobox.
See also
- Parameters:
allowEmpty (bool)
- setConnectionName(self, connection: str | None, provider: str | None = '')[source]¶
Sets the database connection name from which to retrieve the available tables.
Optionally the
providercan be reset too.- Parameters:
connection (Optional[str])
provider (Optional[str] = '')
- setSchema(self, schema: str | None)[source]¶
Sets the
schemafrom which to retrieve the available tables.- Parameters:
schema (Optional[str])
- setTable(self, table: str | None, schema: str | None = '')[source]¶
Sets the current table selected in the combo box.
If necessary, the
schemacan be specified too.- Parameters:
table (Optional[str])
schema (Optional[str] = '')
- signal tableChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.