Class: QgsQueryResultWidget¶
- class qgis.gui.QgsQueryResultWidget¶
Bases:
PyQt5.QtWidgets.QWidget
The
QgsQueryResultWidget
class allows users to enter and run an SQL query on a DB connection (an instance ofQgsAbstractDatabaseProviderConnection
).Query results are displayed in a table view. Query execution and result fetching can be interrupted by pressing the “Stop” push button.
The widget supports a few QueryWidgetMode modes that pre-configure the widget appearance to be used in different contexts like when updating the SQL of an existing query layer.
Note
the ownership of the connection is transferred to the widget.
New in version 3.22.
QgsQueryResultWidget(parent: QWidget = None, connection:
QgsAbstractDatabaseProviderConnection
= None) Creates aQgsQueryResultWidget
with the givenconnection
, ownership is transferred to the widget.Enums
Bases:
enum.IntEnum
Methods
Starts executing the query.
Displays a message with
text
title
andlevel
in the widget's message bar.Sets the connection to
connection
, ownership is transferred to the widget.Convenience method to set the SQL editor text to
sql
.Initializes the widget from
options
.Sets the widget mode to
widgetMode
, default is SqlQueryMode.Hides the result table and shows the error
title
andmessage
in the message bar or in the SQL error panel isisSqlError
is set.Triggered when the threaded API fetcher has new
tokens
to add.Signals
Emitted when a new vector SQL (query) layer must be created.
Emitted when the first batch of results has been fetched.
- class QueryWidgetMode(value)¶
Bases:
enum.IntEnum
The QueryWidgetMode enum represents various modes for the widget appearance.
SqlQueryMode
: Defaults widget mode for SQL execution and SQL query layer creation.QueryLayerUpdateMode
: SQL query layer update mode: the create SQL layer button is renamed to ‘Update’ and the SQL layer creation group box is expanded.
- QueryLayerUpdateMode = 2¶
- SqlQueryMode = 1¶
- baseClass¶
alias of
QgsQueryResultWidget
- actionEvent(self, QActionEvent)¶
- changeEvent(self, QEvent)¶
- childEvent(self, QChildEvent)¶
- closeEvent(self, QCloseEvent)¶
- connectNotify(self, QMetaMethod)¶
- contextMenuEvent(self, QContextMenuEvent)¶
- create(self, window: sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)¶
- createSqlVectorLayer¶
Emitted when a new vector SQL (query) layer must be created.
- Parameters
providerKey (str) – name of the data provider
connectionUri (str) – the connection URI as returned by
QgsAbstractProviderConnection.uri()
options (QgsAbstractDatabaseProviderConnection.SqlVectorLayerOptions) – [signal]
- customEvent(self, QEvent)¶
- destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)¶
- disconnectNotify(self, QMetaMethod)¶
- dragEnterEvent(self, QDragEnterEvent)¶
- dragLeaveEvent(self, QDragLeaveEvent)¶
- dragMoveEvent(self, QDragMoveEvent)¶
- dropEvent(self, QDropEvent)¶
- enterEvent(self, QEvent)¶
- event(self, QEvent) bool ¶
- executeQuery(self)¶
Starts executing the query.
- firstResultBatchFetched¶
Emitted when the first batch of results has been fetched.
Note
If the query returns no results this signal is not emitted. [signal]
- focusInEvent(self, QFocusEvent)¶
- focusNextChild(self) bool ¶
- focusNextPrevChild(self, bool) bool ¶
- focusOutEvent(self, QFocusEvent)¶
- focusPreviousChild(self) bool ¶
- hideEvent(self, QHideEvent)¶
- initPainter(self, QPainter)¶
- inputMethodEvent(self, QInputMethodEvent)¶
- isSignalConnected(self, QMetaMethod) bool ¶
- keyPressEvent(self, QKeyEvent)¶
- keyReleaseEvent(self, QKeyEvent)¶
- leaveEvent(self, QEvent)¶
- metric(self, QPaintDevice.PaintDeviceMetric) int ¶
- mouseDoubleClickEvent(self, QMouseEvent)¶
- mouseMoveEvent(self, QMouseEvent)¶
- mousePressEvent(self, QMouseEvent)¶
- mouseReleaseEvent(self, QMouseEvent)¶
- moveEvent(self, QMoveEvent)¶
- nativeEvent(self, Union[QByteArray, bytes, bytearray], sip.voidptr) Tuple[bool, int] ¶
- notify(self, title: str, text: str, level: Qgis.MessageLevel = Qgis.MessageLevel.Info)¶
Displays a message with
text
title
andlevel
in the widget’s message bar.- Parameters
title (str) –
text (str) –
level (Qgis.MessageLevel = Qgis.MessageLevel.Info) –
- paintEvent(self, QPaintEvent)¶
- receivers(self, PYQT_SIGNAL) int ¶
- resizeEvent(self, QResizeEvent)¶
- sender(self) QObject ¶
- senderSignalIndex(self) int ¶
- setConnection(self, connection: QgsAbstractDatabaseProviderConnection)¶
Sets the connection to
connection
, ownership is transferred to the widget.- Parameters
connection (QgsAbstractDatabaseProviderConnection) –
- setQuery(self, sql: str)¶
Convenience method to set the SQL editor text to
sql
.- Parameters
sql (str) –
- setSqlVectorLayerOptions(self, options: QgsAbstractDatabaseProviderConnection.SqlVectorLayerOptions)¶
Initializes the widget from
options
.- Parameters
options (QgsAbstractDatabaseProviderConnection.SqlVectorLayerOptions) –
- setWidgetMode(self, widgetMode: QgsQueryResultWidget.QueryWidgetMode)¶
Sets the widget mode to
widgetMode
, default is SqlQueryMode.- Parameters
widgetMode (QgsQueryResultWidget.QueryWidgetMode) –
- showError(self, title: str, message: str, isSqlError: bool = False)¶
Hides the result table and shows the error
title
andmessage
in the message bar or in the SQL error panel isisSqlError
is set.- Parameters
title (str) –
message (str) –
isSqlError (bool = False) –
- showEvent(self, QShowEvent)¶
- tabletEvent(self, QTabletEvent)¶
- timerEvent(self, QTimerEvent)¶
- tokensReady(self, tokens: Iterable[str])¶
Triggered when the threaded API fetcher has new
tokens
to add.- Parameters
tokens (Iterable[str]) –
- updateMicroFocus(self)¶
- wheelEvent(self, QWheelEvent)¶