QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
qgsqmlwidgetwrapper.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsqmlwidgetwrapper.h
3
4 ---------------------
5 begin : 25.6.2018
6 copyright : (C) 2018 by Matthias Kuhn
8 ***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16#ifndef QGSQMLWIDGETWRAPPER_H
17#define QGSQMLWIDGETWRAPPER_H
18
19#include "qgswidgetwrapper.h"
20#include "qgis_sip.h"
21#include "qgis_gui.h"
22
23#include <QQuickWidget>
24
30class GUI_EXPORT QgsQmlWidgetWrapper : public QgsWidgetWrapper
31{
32 Q_OBJECT
33
34 public:
42 QgsQmlWidgetWrapper( QgsVectorLayer *layer, QWidget *editor, QWidget *parent );
43
44 bool valid() const override;
45
46 QWidget *createWidget( QWidget *parent ) override;
47
48 void initWidget( QWidget *editor ) override;
49
51 void reinitWidget();
52
54 void setQmlCode( const QString &qmlCode );
55
56 public slots:
57 void setFeature( const QgsFeature &feature ) override;
58
59 private slots:
61 void setQmlContext();
62
63 private:
64 QTemporaryFile mQmlFile;
65 QString mQmlCode;
66 QQuickWidget *mWidget = nullptr;
67 QgsFeature mFeature;
68 QgsFeature mFormFeature;
69 bool mRequiresFormScope = false;
70};
71
72
73#ifndef SIP_RUN
75
81class QmlExpression : public QObject
82{
83 Q_OBJECT
84
85 public:
87 void setExpressionContext( const QgsExpressionContext &context );
88
90 Q_INVOKABLE QVariant evaluate( const QString &expression ) const;
91
92 private:
93 QgsExpressionContext mExpressionContext;
94};
96#endif //SIP_RUN
97
98#endif // QGSQMLWIDGETWRAPPER_H
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:58
Wraps a QQuickWidget to display QML code.
Represents a vector layer which manages a vector based data sets.
Manages an editor widget Widget and wrapper share the same parent.
virtual void setFeature(const QgsFeature &feature)=0
Is called when the value of the widget needs to be changed.
virtual bool valid() const =0
Returns true if the widget has been properly initialized.
virtual void initWidget(QWidget *editor)
This method should initialize the editor widget with runtime data.
virtual QWidget * createWidget(QWidget *parent)=0
This method should create a new widget with the provided parent.