QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
42 mWidget = qobject_cast<QgsWebView *>( editor );
47 mWidget->setHtml( mHtmlCode );
50 #if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
51 const int horizontalDpi = qApp->desktop()->screen()->logicalDpiX();
53 const int horizontalDpi = mWidget->logicalDpiX();
56 mWidget->setZoomFactor( horizontalDpi / 96.0 );
59 connect( page, &QWebPage::contentsChanged,
this, &QgsHtmlWidgetWrapper::fixHeight, Qt::ConnectionType::UniqueConnection );
60 connect( page, &QWebPage::loadFinished,
this, [ = ](
bool ) { fixHeight(); }, Qt::ConnectionType::UniqueConnection );
79 void QgsHtmlWidgetWrapper::setHtmlContext( )
93 HtmlExpression *htmlExpression =
new HtmlExpression();
94 htmlExpression->setExpressionContext( expressionContext );
95 mWidget->page()->settings()->setAttribute( QWebSettings::DeveloperExtrasEnabled,
true );
96 auto frame = mWidget->page()->mainFrame();
97 connect( frame, &QWebFrame::javaScriptWindowObjectCleared, frame, [ = ]
99 frame->addToJavaScriptWindowObject( QStringLiteral(
"expression" ), htmlExpression );
102 mWidget->setHtml( mHtmlCode );
106 void QgsHtmlWidgetWrapper::fixHeight()
109 int docHeight { page->mainFrame()->contentsSize().height() };
110 mWidget->setFixedHeight( docHeight );
126 mExpressionContext = context;
129 QString HtmlExpression::evaluate(
const QString &expression )
const
132 exp.
prepare( &mExpressionContext );
133 return exp.
evaluate( &mExpressionContext ).toString();
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
static QgsExpressionContextScope * formScope(const QgsFeature &formFeature=QgsFeature(), const QString &formMode=QString())
Creates a new scope which contains functions and variables from the current attribute form/table form...
The QWebPage class is a collection of stubs to mimic the API of a QWebPage on systems where QtWebkit ...
bool isValid() const
Returns the validity of this feature.
static QgsExpressionContextScope * parentFormScope(const QgsFeature &formFeature=QgsFeature(), const QString &formMode=QString())
Creates a new scope which contains functions and variables from the current parent attribute form/tab...
QgsFeature parentFormFeature() const
Returns the feature of the currently edited parent form in its actual state.
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
QVariant evaluate()
Evaluate the feature and return the result.
Represents a vector layer which manages a vector based data sets.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QgsExpressionContext createExpressionContext() const FINAL
This method needs to be reimplemented in all classes which implement this interface and return an exp...
Class for parsing and evaluation of expressions (formerly called "search strings").
This class contains context information for attribute editor widgets.
QString attributeFormModeString() const
Returns given attributeFormMode as string.
The QgsWebView class is a collection of stubs to mimic the API of QWebView on systems where the real ...
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.