42 mWidget = qobject_cast<
QgsWebView *>( editor );
47 mWidget->setHtml( mHtmlCode );
49 const int horizontalDpi = qApp->desktop()->screen()->logicalDpiX();
50 mWidget->setZoomFactor( horizontalDpi / 96.0 );
52 auto page = mWidget->page();
53 connect( page, &QWebPage::contentsChanged,
this, [ = ]
55 auto docHeight { page->mainFrame()->contentsSize().height() };
56 mWidget->setFixedHeight( docHeight );
57 }, Qt::ConnectionType::UniqueConnection );
76 void QgsHtmlWidgetWrapper::setHtmlContext( )
86 HtmlExpression *htmlExpression =
new HtmlExpression();
87 htmlExpression->setExpressionContext( expressionContext );
88 mWidget->page()->settings()->setAttribute( QWebSettings::DeveloperExtrasEnabled,
true );
89 auto frame = mWidget->page()->mainFrame();
90 connect( frame, &QWebFrame::javaScriptWindowObjectCleared, frame, [ = ]
92 frame->addToJavaScriptWindowObject( QStringLiteral(
"expression" ), htmlExpression );
95 mWidget->setHtml( mHtmlCode );
113 QString HtmlExpression::evaluate(
const QString &expression )
const 116 exp.
prepare( &mExpressionContext );
117 return exp.
evaluate( &mExpressionContext ).toString();
Class for parsing and evaluation of expressions (formerly called "search strings").
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
This class contains context information for attribute editor widgets.
QVariant evaluate()
Evaluate the feature and return the result.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
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 feat...
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
The QgsWebView class is a collection of stubs to mimic the API of QWebView on systems where the real ...
QgsExpressionContext createExpressionContext() const FINAL
This method needs to be reimplemented in all classes which implement this interface and return an exp...
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
QString attributeFormModeString() const
Returns given attributeFormMode as string.
Represents a vector layer which manages a vector based data sets.