mapwidget.cpp: obtain a reference of the MapWidgetHelper from QML

Use findChild() to obtain the only MapWidgetHelper object created
in the MapWidget.qml. Store the reference as a member variable -
m_mapHelper.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
Lubomir I. Ivanov 2017-07-16 03:16:13 +03:00 committed by Dirk Hohndel
parent 0d75dec0fa
commit 99c2bf6290
2 changed files with 3 additions and 0 deletions

View file

@ -18,6 +18,7 @@ MapWidget::MapWidget(QWidget *parent) : QQuickWidget(parent)
setResizeMode(QQuickWidget::SizeRootObjectToView);
m_rootItem = qobject_cast<QQuickItem *>(rootObject());
m_mapHelper = rootObject()->findChild<MapWidgetHelper *>();
}
void MapWidget::centerOnDiveSite(struct dive_site *ds)

View file

@ -7,6 +7,7 @@
class QResizeEvent;
class QQuickItem;
class MapWidgetHelper;
struct dive_site;
class MapWidget : public QQuickWidget {
@ -33,6 +34,7 @@ public slots:
private:
static MapWidget *m_instance;
QQuickItem *m_rootItem;
MapWidgetHelper *m_mapHelper;
};