Class: QgsQueryBuilder

class qgis.gui.QgsQueryBuilder

Bases: QgsSubsetStringEditorInterface

Query Builder for layers.

The query builder allows interactive creation of a SQL for limiting the features displayed in a vector layer. The fields in the table are displayed and sample values (or all values) can be viewed to aid in constructing the query. A test function returns the number of features that will be returned.

QgsQueryBuilder(layer: QgsVectorLayer, parent: QWidget = None, fl: Union[Qt.WindowFlags, Qt.WindowType] = QgsGuiUtils.ModalDialogFlags) This constructor is used when the query builder is called from the vector layer properties dialog

Parameters:
accept(self)
actionEvent(self, QActionEvent)
changeEvent(self, QEvent)
childEvent(self, QChildEvent)
clear(self)
closeEvent(self, QCloseEvent)
codeEditorWidget(self) QgsCodeEditor

Returns the code editor widget for the SQL.

New in version 3.18.

Return type:

QgsCodeEditor

connectNotify(self, QMetaMethod)
contextMenuEvent(self, QContextMenuEvent)
create(self, window: PyQt5.sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)
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
eventFilter(self, QObject, QEvent) bool
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)
loadQuery(self)

Load query from the XML file

New in version 3.16.

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]
paintEvent(self, QPaintEvent)
receivers(self, PYQT_SIGNAL) int
reject(self)
resizeEvent(self, QResizeEvent)
saveQuery(self)

Save query to the XML file

New in version 3.16.

sender(self) QObject
senderSignalIndex(self) int
setDatasourceDescription(self, uri: str)
Parameters:

uri (str) –

setSql(self, sqlStatement: str)

Set the sql statement to display in the dialog.

Parameters:

sqlStatement (str) –

setSubsetString(self, subsetString: str)
Parameters:

subsetString (str) –

sharedPainter(self) QPainter
showEvent(self, event: QShowEvent)
Parameters:

event (QShowEvent) –

sql(self) str

Returns the sql statement entered in the dialog.

Return type:

str

subsetString(self) str
Return type:

str

tabletEvent(self, QTabletEvent)
test(self)

The default implementation tests that the constructed sql statement to see if the vector layer data provider likes it. The number of rows that would be returned is displayed in a message box. The test uses a “select count(*) from …” query to test the SQL statement.

timerEvent(self, QTimerEvent)
updateMicroFocus(self)
wheelEvent(self, QWheelEvent)