QGIS API Documentation  3.20.0-Odense (decaadbb31)
Public Slots | Signals | Public Member Functions | List of all members
QgsDatabaseTableComboBox Class Reference

The QgsDatabaseTableComboBox class is a combo box which displays the list of tables for a specific database connection. More...

#include <qgsdatabasetablecombobox.h>

Inheritance diagram for QgsDatabaseTableComboBox:
Inheritance graph
[legend]

Public Slots

void refreshTables ()
 Refreshes the list of available tables. More...
 
void setConnectionName (const QString &connection, const QString &provider=QString())
 Sets the database connection name from which to retrieve the available tables. More...
 
void setSchema (const QString &schema)
 Sets the schema from which to retrieve the available tables. More...
 
void setTable (const QString &table, const QString &schema=QString())
 Sets the current table selected in the combo box. More...
 

Signals

void tableChanged (const QString &table, const QString &schema=QString())
 Emitted whenever the currently selected table changes. More...
 

Public Member Functions

 QgsDatabaseTableComboBox (const QString &provider, const QString &connection, const QString &schema=QString(), QWidget *parent=nullptr)
 Constructor for QgsDatabaseTableComboBox, for the specified provider and connection. More...
 
 QgsDatabaseTableComboBox (QgsAbstractDatabaseProviderConnection *connection, const QString &schema=QString(), QWidget *parent=nullptr)
 Constructor for QgsDatabaseTableComboBox, for the specified connection. More...
 
bool allowEmptyTable () const
 Returns true if the combobox allows the empty table ("not set") choice. More...
 
QComboBox * comboBox ()
 Returns the combobox portion of the widget. More...
 
QString currentSchema () const
 Returns the schema of the current table selected in the combo box. More...
 
QString currentTable () const
 Returns the name of the current table selected in the combo box. More...
 
void setAllowEmptyTable (bool allowEmpty)
 Sets whether an optional empty table ("not set") option is present in the combobox. More...
 

Detailed Description

The QgsDatabaseTableComboBox class is a combo box 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.
Since
QGIS 3.14

Definition at line 50 of file qgsdatabasetablecombobox.h.

Constructor & Destructor Documentation

◆ QgsDatabaseTableComboBox() [1/2]

QgsDatabaseTableComboBox::QgsDatabaseTableComboBox ( const QString &  provider,
const QString &  connection,
const QString &  schema = QString(),
QWidget *  parent = nullptr 
)
explicit

Constructor for QgsDatabaseTableComboBox, for the specified provider and connection.

The optional schema argument can be used to restrict the listed tables to a specific schema.

Warning
The provider must support the connection API methods in its QgsProviderMetadata implementation in order for the model to work correctly.

Definition at line 23 of file qgsdatabasetablecombobox.cpp.

◆ QgsDatabaseTableComboBox() [2/2]

QgsDatabaseTableComboBox::QgsDatabaseTableComboBox ( QgsAbstractDatabaseProviderConnection connection,
const QString &  schema = QString(),
QWidget *  parent = nullptr 
)
explicit

Constructor for QgsDatabaseTableComboBox, for the specified connection.

The optional schema argument can be used to restrict the listed tables to a specific schema.

Ownership of connection is transferred to the combobox.

Definition at line 34 of file qgsdatabasetablecombobox.cpp.

Member Function Documentation

◆ allowEmptyTable()

bool QgsDatabaseTableComboBox::allowEmptyTable ( ) const

Returns true if the combobox allows the empty table ("not set") choice.

See also
setAllowEmptyTable()

Definition at line 49 of file qgsdatabasetablecombobox.cpp.

◆ comboBox()

QComboBox* QgsDatabaseTableComboBox::comboBox ( )
inline

Returns the combobox portion of the widget.

Definition at line 100 of file qgsdatabasetablecombobox.h.

◆ currentSchema()

QString QgsDatabaseTableComboBox::currentSchema ( ) const

Returns the schema of the current table selected in the combo box.

Definition at line 172 of file qgsdatabasetablecombobox.cpp.

◆ currentTable()

QString QgsDatabaseTableComboBox::currentTable ( ) const

Returns the name of the current table selected in the combo box.

Definition at line 183 of file qgsdatabasetablecombobox.cpp.

◆ refreshTables

void QgsDatabaseTableComboBox::refreshTables ( )
slot

Refreshes the list of available tables.

Definition at line 163 of file qgsdatabasetablecombobox.cpp.

◆ setAllowEmptyTable()

void QgsDatabaseTableComboBox::setAllowEmptyTable ( bool  allowEmpty)

Sets whether an optional empty table ("not set") option is present in the combobox.

See also
allowEmptyTable()

Definition at line 42 of file qgsdatabasetablecombobox.cpp.

◆ setConnectionName

void QgsDatabaseTableComboBox::setConnectionName ( const QString &  connection,
const QString &  provider = QString() 
)
slot

Sets the database connection name from which to retrieve the available tables.

Optionally the provider can be reset too.

Definition at line 118 of file qgsdatabasetablecombobox.cpp.

◆ setSchema

void QgsDatabaseTableComboBox::setSchema ( const QString &  schema)
slot

Sets the schema from which to retrieve the available tables.

Definition at line 146 of file qgsdatabasetablecombobox.cpp.

◆ setTable

void QgsDatabaseTableComboBox::setTable ( const QString &  table,
const QString &  schema = QString() 
)
slot

Sets the current table selected in the combo box.

If necessary, the schema can be specified too.

Definition at line 87 of file qgsdatabasetablecombobox.cpp.

◆ tableChanged

void QgsDatabaseTableComboBox::tableChanged ( const QString &  table,
const QString &  schema = QString() 
)
signal

Emitted whenever the currently selected table changes.


The documentation for this class was generated from the following files: