Class: QgsQueryBuilder

class qgis.gui.QgsQueryBuilder(layer: QgsVectorLayer, parent: QWidget = None, fl: Union[Qt.WindowFlags, Qt.WindowType] = QgsGuiUtils.ModalDialogFlags)

Bases: QgsSubsetStringEditorInterface

This constructor is used when the query builder is called from the vector layer properties dialog

Parameters
  • layer (QgsVectorLayer) – existing vector layer

  • parent (QWidget = None) – Parent widget

  • fl (Union[Qt.WindowFlags) – dialog flags

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.

Methods

accept

actionEvent

changeEvent

childEvent

clear

closeEvent

codeEditorWidget

Returns the code editor widget for the SQL.

connectNotify

contextMenuEvent

create

customEvent

destroy

disconnectNotify

dragEnterEvent

dragLeaveEvent

dragMoveEvent

dropEvent

enterEvent

event

eventFilter

focusInEvent

focusNextChild

focusNextPrevChild

focusOutEvent

focusPreviousChild

hideEvent

initPainter

inputMethodEvent

isSignalConnected

keyPressEvent

keyReleaseEvent

leaveEvent

loadQuery

Load query from the XML file

metric

mouseDoubleClickEvent

mouseMoveEvent

mousePressEvent

mouseReleaseEvent

moveEvent

nativeEvent

paintEvent

receivers

reject

resizeEvent

saveQuery

Save query to the XML file

sender

senderSignalIndex

setDatasourceDescription

param uri

setSql

Set the sql statement to display in the dialog.

setSubsetString

param subsetString

sharedPainter

showEvent

param event

sql

Returns the sql statement entered in the dialog.

subsetString

rtype

str

tabletEvent

test

The default implementation tests that the constructed sql statement to see if the vector layer data provider likes it.

timerEvent

updateMicroFocus

wheelEvent

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: 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], 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)