aboutsummaryrefslogtreecommitdiffstats
path: root/qmlpage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qmlpage.cpp')
-rw-r--r--qmlpage.cpp32
1 files changed, 29 insertions, 3 deletions
diff --git a/qmlpage.cpp b/qmlpage.cpp
index 277eb61..5d49f5d 100644
--- a/qmlpage.cpp
+++ b/qmlpage.cpp
@@ -2,7 +2,8 @@
#include <QtDeclarative/QDeclarativeView>
#include <QHBoxLayout>
#include <QDebug>
-#include <QDeclarativeContext>
+#include <QGraphicsObject>
+#include <QDeclarativeProperty>
QMLPage::QMLPage(KgpgCore::KgpgKey key, QWidget *parent) :
@@ -14,19 +15,44 @@ QMLPage::QMLPage(KgpgCore::KgpgKey key, QWidget *parent) :
// http://jryannel.wordpress.com/
// http://stackoverflow.com/questions/5594769/normal-desktop-user-interface-controls-with-qml
+
QDeclarativeView *qmlView = new QDeclarativeView;
qmlView->setResizeMode(QDeclarativeView::SizeRootObjectToView);
qmlView->setSource(QUrl("qrc:/qml/keydetails.qml"));
- QDeclarativeContext *context = qmlView->rootContext();
+ context = qmlView->rootContext();
context->setContextProperty("id", key.id());
context->setContextProperty("email", key.email());
context->setContextProperty("name", key.name());
- qDebug() << "qml:::::" << QUrl::fromLocalFile("keydetails.qml");
+ /*
+ or: http://xizhizhu.blogspot.de/2010/10/hybrid-application-using-qml-and-qt-c.html
+ DeclarativePropertyMap map;
+ map.insert("key1", "value1");
+ map.insert("key2", "value2");
+ context->setContextProperty("map", &map);
+
+ */
+
+
+ // http://stackoverflow.com/questions/5947455/connecting-qml-signals-to-qt
+ obj = qmlView->rootObject();
+ connect( obj, SIGNAL(clicked()), this, SLOT(qmlClicked()));
QHBoxLayout *mainLayout = new QHBoxLayout(this);
mainLayout->setSpacing(0);
mainLayout->setContentsMargins(0,0,0,0);
mainLayout->addWidget(qmlView);
+
}
+
+void QMLPage::qmlClicked() {
+
+ // http://stackoverflow.com/questions/9062189/how-to-modify-a-qml-text-from-c
+ qDebug() << "c++, click recieved from qml";
+ qDebug() << "text1" << obj->property("tf1Text").toString();
+
+ //QObject *text2 = obj->findChild<QObject*>("tf2");
+ qDebug() << "text2 "<< obj->property("tf2Text");
+}
+