QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
qgsmaptip.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsmaptips.cpp - Query a layer and show a maptip on the canvas
3 ---------------------
4 begin : October 2007
5 copyright : (C) 2007 by Gary Sherman
6 email : sherman @ mrcc dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15// QGIS includes
16#include "qgsfeatureiterator.h"
17#include "qgsmapcanvas.h"
18#include "qgsmaptool.h"
19#include "qgsvectorlayer.h"
20#include "qgsrasterlayer.h"
21#include "qgsexpression.h"
22#include "qgslogger.h"
23#include "qgssettings.h"
24#include "qgswebview.h"
25#include "qgswebframe.h"
26#include "qgsapplication.h"
27#include "qgsrenderer.h"
30#include "qgsrendercontext.h"
31#include "qgsmapcanvasutils.h"
32
33// Qt includes
34#include <QPoint>
35#include <QToolTip>
36#include <QSettings>
37#include <QLabel>
38#include <QDesktopServices>
39#if WITH_QTWEBKIT
40#include <QWebElement>
41#endif
42#include <QHBoxLayout>
43
44#include "qgsmaptip.h"
45
46
47const QString QgsMapTip::sMapTipTemplate = "<html>\n"
48 " <head>\n"
49 " <style>\n"
50 " body {\n"
51 " margin: 0;\n"
52 " font: %1pt \"%2\";\n"
53 " color: %3;\n"
54 " width: %4px;\n"
55 " }\n"
56 " #QgsWebViewContainer {\n"
57 " background-color: %5;\n"
58 " border: 1px solid %6;\n"
59 " display: inline-block;\n"
60 " margin: 0\n"
61 " }\n"
62 " #QgsWebViewContainerInner {\n"
63 " margin: 5px\n"
64 " }\n"
65 " </style>\n"
66 " </head>\n"
67 " <body>\n"
68 " <div id='QgsWebViewContainer'>\n"
69 " <div id='QgsWebViewContainerInner'>\n"
70 " %7\n"
71 " </div>\n"
72 " </div>\n"
73 " </body>\n"
74 "</html>\n";
75
76
78{
79 // Init the visible flag
80 mMapTipVisible = false;
81
82 mDelayedClearTimer.setSingleShot( true );
83 connect( &mDelayedClearTimer, &QTimer::timeout, this, [ = ]() {this->clear();} );
84}
85
87 QgsPointXY &mapPosition,
88 const QPoint &pixelPosition,
89 QgsMapCanvas *pMapCanvas )
90{
91 // Do the search using the active layer and the preferred label field for the
92 // layer. The label field must be defined in the layer configuration
93 // file/database. The code required to do this is similar to identify, except
94 // we only want the first qualifying feature and we will only display the
95 // field defined as the label field in the layer configuration file/database
96
97 // Do not render map tips if the layer is not visible
98 if ( !pMapCanvas->layers( true ).contains( pLayer ) )
99 {
100 return;
101 }
102
103 // Do not render a new map tip when the mouse hovers an existing one
104 if ( mWebView && mWebView->underMouse() )
105 {
106 return;
107 }
108
109 // Show the maptip on the canvas
110 QString tipText, lastTipText, tipHtml;
111
112 if ( ! mWebView )
113 {
114 mWebView = new QgsWebView( pMapCanvas );
115 // Make the webwiew transparent
116 mWebView->setStyleSheet( QStringLiteral( "background:transparent;" ) );
117
118
119#if WITH_QTWEBKIT
120 mWebView->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );//Handle link clicks by yourself
121 mWebView->setContextMenuPolicy( Qt::NoContextMenu ); //No context menu is allowed if you don't need it
122 connect( mWebView, &QWebView::linkClicked, this, &QgsMapTip::onLinkClicked );
123 connect( mWebView, &QWebView::loadFinished, this, [ = ]( bool ) { resizeAndMoveToolTip(); } );
124#endif
125
126 mWebView->page()->settings()->setAttribute( QWebSettings::DeveloperExtrasEnabled, true );
127 mWebView->page()->settings()->setAttribute( QWebSettings::JavascriptEnabled, true );
128 mWebView->page()->settings()->setAttribute( QWebSettings::LocalStorageEnabled, true );
129
130 // Disable scrollbars, avoid random resizing issues
131 mWebView->page()->mainFrame()->setScrollBarPolicy( Qt::Horizontal, Qt::ScrollBarAlwaysOff );
132 mWebView->page()->mainFrame()->setScrollBarPolicy( Qt::Vertical, Qt::ScrollBarAlwaysOff );
133
134 }
135
136 // Only supported layer types here:
137 switch ( pLayer->type() )
138 {
139 case Qgis::LayerType::Vector:
140 tipText = fetchFeature( pLayer, mapPosition, pMapCanvas );
141 break;
142 case Qgis::LayerType::Raster:
143 tipText = fetchRaster( pLayer, mapPosition, pMapCanvas );
144 break;
145 default:
146 break;
147 }
148
149 mMapTipVisible = !tipText.isEmpty();
150 if ( !mMapTipVisible )
151 {
152 clear();
153 return;
154 }
155
156 if ( tipText == lastTipText )
157 {
158 return;
159 }
160
161 // Compute offset from the cursor position
162 int cursorOffset = 0;
164 {
165 // The following calculations are taken
166 // from QgsApplication::getThemeCursor, and are used to calculate the correct cursor size
167 // for both hi-dpi and non-hi-dpi screens.
168 double scale = Qgis::UI_SCALE_FACTOR * QgsApplication::instance()->fontMetrics().height() / 32.0;
169 cursorOffset = static_cast< int >( std::ceil( scale * 32 ) );
170 }
171
172 // Ensures the map tip is never larger than half the map canvas minus the cursor size + margin (cursorOffset)
173 const int MAX_WIDTH = pMapCanvas->width() / 2 - cursorOffset;
174 const int MAX_HEIGHT = pMapCanvas->height() / 2;
175
176 mWebView->setMaximumSize( MAX_WIDTH, MAX_HEIGHT );
177
178 tipHtml = QgsMapTip::htmlText( tipText, MAX_WIDTH );
179
180 QgsDebugMsgLevel( tipHtml, 2 );
181
182 mPosition = pixelPosition;
183 mMapCanvas = pMapCanvas;
184 mWebView->setHtml( tipHtml );
185 lastTipText = tipText;
186
187#if !WITH_QTWEBKIT
188 resizeAndMoveToolTip();
189#endif
190
191}
192
193void QgsMapTip::resizeAndMoveToolTip()
194{
195#if WITH_QTWEBKIT
196 // Get the content size
197 const QWebElement container = mWebView->page()->mainFrame()->findFirstElement(
198 QStringLiteral( "#QgsWebViewContainer" ) );
199 const int width = container.geometry().width();
200 const int height = container.geometry().height();
201 mWebView->resize( width, height );
202#else
203 mWebView->adjustSize();
204#endif
205
206 int cursorOffset = 0;
207 // attempt to shift the tip away from the cursor.
209 {
210 // The following calculations are taken
211 // from QgsApplication::getThemeCursor, and are used to calculate the correct cursor size
212 // for both hi-dpi and non-hi-dpi screens.
213 double scale = Qgis::UI_SCALE_FACTOR * QgsApplication::instance()->fontMetrics().height() / 32.0;
214 cursorOffset = static_cast< int >( std::ceil( scale * 32 ) );
215 }
216
217 if ( mMapCanvas == nullptr )
218 {
219 mWebView->move( mPosition );
220 mWebView->show();
221 return;
222 }
223
224 // Check if there is enough space to the right of the cursor
225 int availableWidthRight = mMapCanvas->width() - mPosition.x() - cursorOffset;
226 int availableWidthLeft = mPosition.x() - cursorOffset;
227 int availableHeightBottom = mMapCanvas->height() - mPosition.y();
228 int availableHeightTop = mPosition.y();
229 int x, y;
230 // If there is enough space on the right, or more space on the right than on the left, move the map tip to the right of the cursor
231 if ( mWebView->width() < availableWidthRight || availableWidthRight > availableWidthLeft )
232 {
233 x = mPosition.x() + cursorOffset;
234 }
235 // Otherwise, move the map tip to the left of the cursor
236 else
237 {
238 x = mPosition.x() - mWebView->width() - cursorOffset;
239 }
240
241 // If there is enough space on the bottom, or more space on the bottom than on the top, move the map tip to the bottom of the cursor
242 if ( mWebView->height() < availableHeightBottom || availableHeightBottom > availableHeightTop )
243 {
244 y = mPosition.y();
245 }
246 // Otherwise, move the map tip to the top of the cursor
247 else
248 {
249 y = mPosition.y() - mWebView->height();
250 }
251 mWebView->move( x, y );
252 mWebView->show();
253}
254
255void QgsMapTip::clear( QgsMapCanvas *, int msDelay )
256{
257 if ( !mMapTipVisible )
258 {
259 return;
260 }
261
262 // Skip clearing the map tip if the user interacts with it or the timer still runs
263 if ( mDelayedClearTimer.isActive() || mWebView->underMouse() )
264 {
265 return;
266 }
267
268 if ( msDelay > 0 )
269 {
270 mDelayedClearTimer.start( msDelay );
271 return;
272 }
273 mWebView->setHtml( QString() );
274 mWebView->hide();
275
276 // Reset the visible flag
277 mMapTipVisible = false;
278}
279
280QString QgsMapTip::fetchFeature( QgsMapLayer *layer, QgsPointXY &mapPosition, QgsMapCanvas *mapCanvas )
281{
282 QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
283 if ( !vlayer || !vlayer->isSpatial() || !vlayer->mapTipsEnabled() )
284 {
285 return QString();
286 }
287
288 if ( !layer->isInScaleRange( mapCanvas->mapSettings().scale() ) ||
289 ( mapCanvas->mapSettings().isTemporal() && !layer->temporalProperties()->isVisibleInTemporalRange( mapCanvas->temporalRange() ) ) )
290 {
291 return QString();
292 }
293
294 const double searchRadius = QgsMapTool::searchRadiusMU( mapCanvas );
295
296 QgsRectangle r;
297 r.setXMinimum( mapPosition.x() - searchRadius );
298 r.setYMinimum( mapPosition.y() - searchRadius );
299 r.setXMaximum( mapPosition.x() + searchRadius );
300 r.setYMaximum( mapPosition.y() + searchRadius );
301
302 r = mapCanvas->mapSettings().mapToLayerCoordinates( layer, r );
303
305 context.appendScope( QgsExpressionContextUtils::mapSettingsScope( mapCanvas->mapSettings() ) );
306 context.appendScope( QgsExpressionContextUtils::mapLayerPositionScope( r.center() ) );
307
308 const QString canvasFilter = QgsMapCanvasUtils::filterForLayer( mapCanvas, vlayer );
309 if ( canvasFilter == QLatin1String( "FALSE" ) )
310 {
311 return QString();
312 }
313
314 const QString mapTip = vlayer->mapTipTemplate();
315 QString tipString;
316 QgsExpression exp( vlayer->displayExpression() );
317 QgsFeature feature;
318
319 QgsFeatureRequest request;
320 request.setFilterRect( r );
322 if ( !canvasFilter.isEmpty() )
323 {
324 request.setFilterExpression( canvasFilter );
325 }
326
327 if ( mapTip.isEmpty() )
328 {
329 exp.prepare( &context );
330 request.setSubsetOfAttributes( exp.referencedColumns(), vlayer->fields() );
331 }
332
334 renderCtx.setExpressionContext( mapCanvas->createExpressionContext() );
336
337 bool filter = false;
338 std::unique_ptr< QgsFeatureRenderer > renderer;
339 if ( vlayer->renderer() )
340 {
341 renderer.reset( vlayer->renderer()->clone() );
342 renderer->startRender( renderCtx, vlayer->fields() );
343 filter = renderer->capabilities() & QgsFeatureRenderer::Filter;
344
345 const QString filterExpression = renderer->filter( vlayer->fields() );
346 if ( ! filterExpression.isEmpty() )
347 {
348 request.combineFilterExpression( filterExpression );
349 }
350 }
351 request.setExpressionContext( renderCtx.expressionContext() );
352
353 QgsFeatureIterator it = vlayer->getFeatures( request );
354 QElapsedTimer timer;
355 timer.start();
356 while ( it.nextFeature( feature ) )
357 {
358 context.setFeature( feature );
359
360 renderCtx.expressionContext().setFeature( feature );
361 if ( filter && renderer && !renderer->willRenderFeature( feature, renderCtx ) )
362 {
363 continue;
364 }
365
366 if ( !mapTip.isEmpty() )
367 {
368 tipString = QgsExpression::replaceExpressionText( mapTip, &context );
369 }
370 else
371 {
372 tipString = exp.evaluate( &context ).toString();
373 }
374
375 if ( !tipString.isEmpty() || timer.elapsed() >= 1000 )
376 {
377 break;
378 }
379 }
380
381 if ( renderer )
382 {
383 renderer->stopRender( renderCtx );
384 }
385
386 return tipString;
387}
388
389QString QgsMapTip::fetchRaster( QgsMapLayer *layer, QgsPointXY &mapPosition, QgsMapCanvas *mapCanvas )
390{
391 QgsRasterLayer *rlayer = qobject_cast<QgsRasterLayer *>( layer );
392 if ( !rlayer || !rlayer->mapTipsEnabled() )
393 {
394 return QString();
395 }
396
397 if ( !layer->isInScaleRange( mapCanvas->mapSettings().scale() ) ||
398 ( mapCanvas->mapSettings().isTemporal() && !layer->temporalProperties()->isVisibleInTemporalRange( mapCanvas->temporalRange() ) ) )
399 {
400 return QString();
401 }
402
403 if ( rlayer->mapTipTemplate().isEmpty() )
404 {
405 return QString();
406 }
407
408 const QgsPointXY mappedPosition { mapCanvas->mapSettings().mapToLayerCoordinates( layer, mapPosition ) };
409
410 if ( ! layer->extent().contains( mappedPosition ) )
411 {
412 return QString();
413 }
414
416 context.appendScope( QgsExpressionContextUtils::mapSettingsScope( mapCanvas->mapSettings() ) );
417 context.appendScope( QgsExpressionContextUtils::mapLayerPositionScope( mappedPosition ) );
418 return QgsExpression::replaceExpressionText( rlayer->mapTipTemplate(), &context );
419}
420
421QString QgsMapTip::htmlText( const QString &text, int maxWidth )
422{
423
424 const QgsSettings settings;
425 const QFont defaultFont = qApp->font();
426 const int fontSize = defaultFont.pointSize();
427 const QString fontFamily = defaultFont.family();
428 const QString backgroundColor = QgsApplication::palette().base().color().name();
429 const QString strokeColor = QgsApplication::palette().shadow().color().name();
430 const QString textColor = QgsApplication::palette().toolTipText().color().name();
431 return sMapTipTemplate.arg( fontSize ).arg( fontFamily ).arg( textColor ).arg( maxWidth == -1 ? "" : QString::number( maxWidth ) ).arg( backgroundColor ).arg( strokeColor ).arg( text );
432}
433
434// This slot handles all clicks
435void QgsMapTip::onLinkClicked( const QUrl &url )
436{
437 QDesktopServices::openUrl( url );
438}
439
440
441QString QgsMapTip::vectorMapTipPreviewText( QgsMapLayer *layer, QgsMapCanvas *mapCanvas, const QString &mapTemplate, const QString &displayExpression )
442{
443 // Only spatial layers can have map tips
444 QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
445 if ( !mapCanvas || !vlayer || !vlayer->isSpatial() )
446 return QString();
447
448 // If no map tip template or display expression is set, return an empty string
449 if ( mapTemplate.isEmpty() && displayExpression.isEmpty() )
450 return QString();
451
452 // Create an expression context
455
456 // Get the first feature if any, and add it to the expression context
457 QgsFeature previewFeature;
458 if ( vlayer->featureCount() > 0 )
459 {
460 QgsFeatureIterator it = vlayer->getFeatures( QgsFeatureRequest().setLimit( 1 ) );
461 it.nextFeature( previewFeature );
462 }
463 else
464 {
465 previewFeature = QgsFeature( vlayer->fields() );
466 }
467 context.setFeature( previewFeature );
468
469 // Generate the map tip text from the context and the mapTipTemplate/displayExpression
470 QString tipText;
471 if ( mapTemplate.isEmpty() )
472 {
473 QgsExpression exp( displayExpression );
474 exp.prepare( &context );
475 tipText = exp.evaluate( &context ).toString();
476 }
477 else
478 {
479 tipText = QgsExpression::replaceExpressionText( mapTemplate, &context );
480 }
481
482 // Insert the map tip text into the html template
483 return QgsMapTip::htmlText( tipText, mapCanvas->width() / 2 );
484
485}
486
487QString QgsMapTip::rasterMapTipPreviewText( QgsMapLayer *layer, QgsMapCanvas *mapCanvas, const QString &mapTemplate )
488{
489 QgsRasterLayer *rlayer = qobject_cast<QgsRasterLayer *>( layer );
490 if ( !mapCanvas || !rlayer || mapTemplate.isEmpty() )
491 {
492 return QString();
493 }
494
495 // Create an expression context
498
499 // Get the position of the center of the layer, and add it to the expression context
500 const QgsPointXY mappedPosition { layer->extent().center() };
502
503 // Generate the map tip text from the context and the mapTipTemplate
504 const QString tipText = QgsExpression::replaceExpressionText( mapTemplate, &context );
505
506 // Insert the map tip text into the html template
507 return QgsMapTip::htmlText( tipText, mapCanvas->width() / 2 );
508}
static const double UI_SCALE_FACTOR
UI scaling factor.
Definition: qgis.h:3749
static QgsApplication * instance()
Returns the singleton instance of the QgsApplication.
static QgsExpressionContextScope * mapLayerPositionScope(const QgsPointXY &position)
Sets the expression context variables which are available for expressions triggered by moving the mou...
static QgsExpressionContextScope * mapSettingsScope(const QgsMapSettings &mapSettings)
Creates a new scope which contains variables and functions relating to a QgsMapSettings object.
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
Class for parsing and evaluation of expressions (formerly called "search strings").
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
static QString replaceExpressionText(const QString &action, const QgsExpressionContext *context, const QgsDistanceArea *distanceArea=nullptr)
This function replaces each expression between [% and %] in the string with the result of its evaluat...
QVariant evaluate()
Evaluate the feature and return the result.
Wrapper for iterator of features from vector data provider or vector layer.
bool nextFeature(QgsFeature &f)
@ Filter
Features may be filtered, i.e. some features may not be rendered (categorized, rule based ....
Definition: qgsrenderer.h:275
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
This class wraps a request for features to a vector layer (or directly its vector data provider).
QgsFeatureRequest & combineFilterExpression(const QString &expression)
Modifies the existing filter expression to add an additional expression filter.
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
@ ExactIntersect
Use exact geometry intersection (slower) instead of bounding boxes.
QgsFeatureRequest & setExpressionContext(const QgsExpressionContext &context)
Sets the expression context used to evaluate filter expressions.
QgsFeatureRequest & setFilterRect(const QgsRectangle &rectangle)
Sets the rectangle from which features will be taken.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:56
static QString filterForLayer(QgsMapCanvas *canvas, QgsVectorLayer *layer)
Constructs a filter to use for selecting features from the given layer, in order to apply filters whi...
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:90
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
const QgsDateTimeRange & temporalRange() const
Returns map canvas datetime range.
QList< QgsMapLayer * > layers(bool expandGroupLayers=false) const
Returns the list of layers shown within the map canvas.
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
virtual bool isVisibleInTemporalRange(const QgsDateTimeRange &range) const
Returns true if the layer should be visible and rendered for the specified time range.
Base class for all map layer types.
Definition: qgsmaplayer.h:73
bool isInScaleRange(double scale) const
Tests whether the layer should be visible at the specified scale.
virtual QgsRectangle extent() const
Returns the extent of the layer.
Qgis::LayerType type
Definition: qgsmaplayer.h:80
virtual QgsMapLayerTemporalProperties * temporalProperties()
Returns the layer's temporal properties.
Definition: qgsmaplayer.h:1526
bool mapTipsEnabled
Definition: qgsmaplayer.h:84
QString mapTipTemplate
Definition: qgsmaplayer.h:83
double scale() const
Returns the calculated map scale.
QgsPointXY mapToLayerCoordinates(const QgsMapLayer *layer, QgsPointXY point) const
transform point coordinates from output CRS to layer's CRS
void showMapTip(QgsMapLayer *thepLayer, QgsPointXY &mapPosition, const QPoint &pixelPosition, QgsMapCanvas *mpMapCanvas)
Show a maptip at a given point on the map canvas.
Definition: qgsmaptip.cpp:86
static QString rasterMapTipPreviewText(QgsMapLayer *layer, QgsMapCanvas *mapCanvas, const QString &mapTemplate)
Returns the html that would be displayed in a maptip for a given layer.
Definition: qgsmaptip.cpp:487
static QString vectorMapTipPreviewText(QgsMapLayer *layer, QgsMapCanvas *mapCanvas, const QString &mapTemplate, const QString &displayExpression)
Returns the html that would be displayed in a maptip for a given layer.
Definition: qgsmaptip.cpp:441
QgsMapTip()
Default constructor.
Definition: qgsmaptip.cpp:77
void clear(QgsMapCanvas *mpMapCanvas=nullptr, int msDelay=0)
Clear the current maptip if it exists.
Definition: qgsmaptip.cpp:255
static double searchRadiusMU(const QgsRenderContext &context)
Gets search radius in map units for given context.
Definition: qgsmaptool.cpp:238
A class to represent a 2D point.
Definition: qgspointxy.h:59
double y
Definition: qgspointxy.h:63
Q_GADGET double x
Definition: qgspointxy.h:62
Represents a raster layer.
A rectangle specified with double values.
Definition: qgsrectangle.h:42
void setYMinimum(double y) SIP_HOLDGIL
Set the minimum y value.
Definition: qgsrectangle.h:161
void setXMaximum(double x) SIP_HOLDGIL
Set the maximum x value.
Definition: qgsrectangle.h:156
void setXMinimum(double x) SIP_HOLDGIL
Set the minimum x value.
Definition: qgsrectangle.h:151
void setYMaximum(double y) SIP_HOLDGIL
Set the maximum y value.
Definition: qgsrectangle.h:166
bool contains(const QgsRectangle &rect) const SIP_HOLDGIL
Returns true when rectangle contains other rectangle.
Definition: qgsrectangle.h:363
QgsPointXY center() const SIP_HOLDGIL
Returns the center point of the rectangle.
Definition: qgsrectangle.h:251
Contains information about the context of a rendering operation.
QgsExpressionContext & expressionContext()
Gets the expression context.
static QgsRenderContext fromMapSettings(const QgsMapSettings &mapSettings)
create initialized QgsRenderContext instance from given QgsMapSettings
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
This class is a composition of two QSettings instances:
Definition: qgssettings.h:63
bool isTemporal() const
Returns true if the object's temporal range is enabled, and the object will be filtered when renderin...
Represents a vector layer which manages a vector based data sets.
long long featureCount(const QString &legendKey) const
Number of features rendered with specified legend key.
bool isSpatial() const FINAL
Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeome...
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Queries the layer for features specified in request.
QgsFields fields() const FINAL
Returns the list of fields of this layer.
QgsFeatureRenderer * renderer()
Returns the feature renderer used for rendering the features in the layer in 2D map views.
QString displayExpression
The QgsWebView class is a collection of stubs to mimic the API of QWebView on systems where the real ...
Definition: qgswebview.h:66
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39