Skip to content
Permalink
Browse files

get attributes from current feature

by feature.attribute("outlet_1")
  • Loading branch information
signedav committed Sep 5, 2018
1 parent e8e32fa commit 016b0cb76a81bcf78c1d66a6598209370eb0196e
Showing with 9 additions and 4 deletions.
  1. +7 −4 src/gui/editorwidgets/qgsqmlwidgetwrapper.cpp
  2. +2 −0 src/gui/editorwidgets/qgsqmlwidgetwrapper.h
@@ -16,6 +16,8 @@
#include "qgsqmlwidgetwrapper.h"
#include "qgsmessagelog.h"
#include <QtQuickWidgets/QQuickWidget>
#include <QQuickWidget>
#include <QQmlContext>

QgsQmlWidgetWrapper::QgsQmlWidgetWrapper( QgsVectorLayer *layer, QWidget *editor, QWidget *parent )
: QgsWidgetWrapper( layer, editor, parent )
@@ -35,9 +37,9 @@ QWidget *QgsQmlWidgetWrapper::createWidget( QWidget *parent )

void QgsQmlWidgetWrapper::initWidget( QWidget *editor )
{
QQuickWidget *quickWidget = qobject_cast<QQuickWidget *>( editor );
mWidget = qobject_cast<QQuickWidget *>( editor );

if ( !quickWidget )
if ( !mWidget )
return;


@@ -47,7 +49,7 @@ void QgsQmlWidgetWrapper::initWidget( QWidget *editor )
return;
}

quickWidget->setSource( QUrl::fromLocalFile( mQmlFile.fileName() ) );
mWidget->setSource( QUrl::fromLocalFile( mQmlFile.fileName() ) );

mQmlFile.close();
}
@@ -67,5 +69,6 @@ void QgsQmlWidgetWrapper::setQmlCode( const QString &qmlCode )

void QgsQmlWidgetWrapper::setFeature( const QgsFeature &feature )
{

if ( mWidget )
mWidget->rootContext()->setContextProperty( "feature", feature );
}
@@ -45,6 +45,8 @@ class GUI_EXPORT QgsQmlWidgetWrapper : public QgsWidgetWrapper
QTemporaryFile mQmlFile;

QQuickWidget *mWidget = nullptr;

QgsFeature mFeature;
};

#endif // QGSQMLWIDGETWRAPPER_H

0 comments on commit 016b0cb

Please sign in to comment.
You can’t perform that action at this time.