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
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
- 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: PyQt5.sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)¶
- createSqlVectorLayer¶
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.
- Parameters:
name (str = ...) –
revision (int = ...) –
arguments (Sequence = ...) –
- Return type:
PYQT_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¶
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.
- Parameters:
name (str = ...) –
revision (int = ...) –
arguments (Sequence = ...) –
- Return type:
PYQT_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], PyQt5.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)¶