QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
20 #include <QtQuickWidgets/QQuickWidget>
21 #include <QQuickWidget>
22 #include <QQmlContext>
38 return new QQuickWidget( parent );
43 mWidget = qobject_cast<QQuickWidget *>( editor );
49 if ( !mQmlFile.open() )
55 mWidget->setSource( QUrl::fromLocalFile( mQmlFile.fileName() ) );
66 mWidget->engine()->clearComponentCache();
73 if ( !mQmlFile.open() )
80 mQmlFile.write( qmlCode.toUtf8() );
85 void QgsQmlWidgetWrapper::setQmlContext( )
95 QmlExpression *qmlExpression =
new QmlExpression();
96 qmlExpression->setExpressionContext( expressionContext );
98 mWidget->rootContext()->setContextProperty(
"expression", qmlExpression );
114 mExpressionContext = context;
117 QVariant QmlExpression::evaluate(
const QString &expression )
const
120 exp.
prepare( &mExpressionContext );
121 return exp.
evaluate( &mExpressionContext );
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...
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
QVariant evaluate()
Evaluate the feature and return the result.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
QgsExpressionContext createExpressionContext() const FINAL
This method needs to be reimplemented in all classes which implement this interface and return an exp...
QString attributeFormModeString() const
Returns given attributeFormMode as string.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.