QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
Public Slots | Public Member Functions | Static Public Member Functions | Friends | List of all members
QgsQueryBuilder Class Reference

Query Builder for layers. More...

#include <qgsquerybuilder.h>

Inheritance diagram for QgsQueryBuilder:
Inheritance graph
[legend]

Public Slots

void accept () override
 
void clear ()
 
void loadQuery ()
 Load query from the XML file. More...
 
void reject () override
 
void saveQuery ()
 Save query to the XML file. More...
 
void setDatasourceDescription (const QString &uri)
 
virtual void test ()
 The default implementation tests that the constructed sql statement to see if the vector layer data provider likes it. More...
 

Public Member Functions

 QgsQueryBuilder (QgsVectorLayer *layer, QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags)
 This constructor is used when the query builder is called from the vector layer properties dialog. More...
 
QgsCodeEditorcodeEditorWidget () const
 Returns the code editor widget for the SQL. More...
 
void setSql (const QString &sqlStatement)
 Set the sql statement to display in the dialog. More...
 
void setSubsetString (const QString &subsetString) override
 Sets a subset string into the dialog. More...
 
void showEvent (QShowEvent *event) override
 
QString sql () const
 Returns the sql statement entered in the dialog. More...
 
QString subsetString () const override
 Returns the subset string entered in the dialog. More...
 
- Public Member Functions inherited from QgsSubsetStringEditorInterface
 QgsSubsetStringEditorInterface (QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags)
 Constructor. More...
 
virtual void setSubsetString (const QString &subsetString)=0
 Sets a subset string into the dialog. More...
 
virtual QString subsetString () const =0
 Returns the subset string entered in the dialog. More...
 

Static Public Member Functions

static bool loadQueryFromFile (QString &subset)
 Load query from the XML file. More...
 
static bool saveQueryToFile (const QString &subset)
 Save query to the XML file. More...
 

Friends

class TestQgsQueryBuilder
 

Detailed Description

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.

Definition at line 45 of file qgsquerybuilder.h.

Constructor & Destructor Documentation

◆ QgsQueryBuilder()

QgsQueryBuilder::QgsQueryBuilder ( QgsVectorLayer layer,
QWidget *  parent = nullptr,
Qt::WindowFlags  fl = QgsGuiUtils::ModalDialogFlags 
)

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

Parameters
layerexisting vector layer
parentParent widget
fldialog flags

Definition at line 38 of file qgsquerybuilder.cpp.

Member Function Documentation

◆ accept

void QgsQueryBuilder::accept ( )
overrideslot

Definition at line 259 of file qgsquerybuilder.cpp.

◆ clear

void QgsQueryBuilder::clear ( )
slot

Definition at line 423 of file qgsquerybuilder.cpp.

◆ codeEditorWidget()

QgsCodeEditor * QgsQueryBuilder::codeEditorWidget ( ) const
inline

Returns the code editor widget for the SQL.

Since
QGIS 3.18

Definition at line 94 of file qgsquerybuilder.h.

◆ loadQuery

void QgsQueryBuilder::loadQuery ( )
slot

Load query from the XML file.

Since
QGIS 3.16

Definition at line 488 of file qgsquerybuilder.cpp.

◆ loadQueryFromFile()

bool QgsQueryBuilder::loadQueryFromFile ( QString &  subset)
static

Load query from the XML file.

Since
QGIS 3.26

Definition at line 498 of file qgsquerybuilder.cpp.

◆ reject

void QgsQueryBuilder::reject ( )
overrideslot

Definition at line 286 of file qgsquerybuilder.cpp.

◆ saveQuery

void QgsQueryBuilder::saveQuery ( )
slot

Save query to the XML file.

Since
QGIS 3.16

Definition at line 445 of file qgsquerybuilder.cpp.

◆ saveQueryToFile()

bool QgsQueryBuilder::saveQueryToFile ( const QString &  subset)
static

Save query to the XML file.

Since
QGIS 3.26

Definition at line 451 of file qgsquerybuilder.cpp.

◆ setDatasourceDescription

void QgsQueryBuilder::setDatasourceDescription ( const QString &  uri)
slot

Definition at line 435 of file qgsquerybuilder.cpp.

◆ setSql()

void QgsQueryBuilder::setSql ( const QString &  sqlStatement)

Set the sql statement to display in the dialog.

Definition at line 341 of file qgsquerybuilder.cpp.

◆ setSubsetString()

void QgsQueryBuilder::setSubsetString ( const QString &  subsetString)
inlineoverridevirtual

Sets a subset string into the dialog.

Implements QgsSubsetStringEditorInterface.

Definition at line 69 of file qgsquerybuilder.h.

◆ showEvent()

void QgsQueryBuilder::showEvent ( QShowEvent *  event)
override

Definition at line 104 of file qgsquerybuilder.cpp.

◆ sql()

QString QgsQueryBuilder::sql ( ) const

Returns the sql statement entered in the dialog.

Definition at line 336 of file qgsquerybuilder.cpp.

◆ subsetString()

QString QgsQueryBuilder::subsetString ( ) const
inlineoverridevirtual

Returns the subset string entered in the dialog.

Implements QgsSubsetStringEditorInterface.

Definition at line 68 of file qgsquerybuilder.h.

◆ test

void QgsQueryBuilder::test ( )
virtualslot

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.

Definition at line 220 of file qgsquerybuilder.cpp.

Friends And Related Function Documentation

◆ TestQgsQueryBuilder

friend class TestQgsQueryBuilder
friend

Definition at line 200 of file qgsquerybuilder.h.


The documentation for this class was generated from the following files: