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: Optional[QgsVectorLayer], parent: Optional[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, a0: QActionEvent | None)
changeEvent(self, a0: QEvent | None)
childEvent(self, a0: QChildEvent | None)
clear(self)
closeEvent(self, a0: QCloseEvent | None)
codeEditorWidget(self) QgsCodeEditor | None

Returns the code editor widget for the SQL.

Added in version 3.18.

Return type:

Optional[QgsCodeEditor]

connectNotify(self, signal: QMetaMethod)
contextMenuEvent(self, a0: QContextMenuEvent | None)
create(self, window: PyQt5.sip.voidptr = None, initializeWindow: bool = True, destroyOldWindow: bool = True)
customEvent(self, a0: QEvent | None)
destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)
disconnectNotify(self, signal: QMetaMethod)
dragEnterEvent(self, a0: QDragEnterEvent | None)
dragLeaveEvent(self, a0: QDragLeaveEvent | None)
dragMoveEvent(self, a0: QDragMoveEvent | None)
dropEvent(self, a0: QDropEvent | None)
enterEvent(self, a0: QEvent | None)
event(self, a0: QEvent | None) bool
eventFilter(self, a0: QObject | None, a1: QEvent | None) bool
focusInEvent(self, a0: QFocusEvent | None)
focusNextChild(self) bool
focusNextPrevChild(self, next: bool) bool
focusOutEvent(self, a0: QFocusEvent | None)
focusPreviousChild(self) bool
hideEvent(self, a0: QHideEvent | None)
initPainter(self, painter: QPainter | None)
inputMethodEvent(self, a0: QInputMethodEvent | None)
isSignalConnected(self, signal: QMetaMethod) bool
keyPressEvent(self, a0: QKeyEvent | None)
keyReleaseEvent(self, a0: QKeyEvent | None)
leaveEvent(self, a0: QEvent | None)
loadQuery(self)

Load query from the XML file

Added in version 3.16.

loadQueryFromFile(subset: str | None) bool

Load query from the XML file

Added in version 3.26.

Parameters:

subset (Optional[str])

Return type:

bool

metric(self, a0: QPaintDevice.PaintDeviceMetric) int
mouseDoubleClickEvent(self, a0: QMouseEvent | None)
mouseMoveEvent(self, a0: QMouseEvent | None)
mousePressEvent(self, a0: QMouseEvent | None)
mouseReleaseEvent(self, a0: QMouseEvent | None)
moveEvent(self, a0: QMoveEvent | None)
nativeEvent(self, eventType: QByteArray | bytes | bytearray, message: PyQt5.sip.voidptr | None)
paintEvent(self, a0: QPaintEvent | None)
receivers(self, signal: PYQT_SIGNAL) int
reject(self)
resizeEvent(self, a0: QResizeEvent | None)
saveQuery(self)

Save query to the XML file

Added in version 3.16.

saveQueryToFile(subset: str | None) bool

Save query to the XML file

Added in version 3.26.

Parameters:

subset (Optional[str])

Return type:

bool

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

uri (Optional[str])

setSql(self, sqlStatement: str | None)

Set the sql statement to display in the dialog.

Parameters:

sqlStatement (Optional[str])

setSubsetString(self, subsetString: str | None)
Parameters:

subsetString (Optional[str])

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

event (Optional[QShowEvent])

sql(self) str

Returns the sql statement entered in the dialog.

Return type:

str

subsetString(self) str
Return type:

str

tabletEvent(self, a0: QTabletEvent | None)
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, a0: QTimerEvent | None)
updateMicroFocus(self)
wheelEvent(self, a0: QWheelEvent | None)