Skip to content

Instantly share code, notes, and snippets.

@Avanznow
Created January 27, 2014 04:38
Show Gist options
  • Save Avanznow/8643364 to your computer and use it in GitHub Desktop.
Save Avanznow/8643364 to your computer and use it in GitHub Desktop.
Signal Data Exchange in C++Qt/QML for Android/iOS/WP8
#include <QtGui/QGuiApplication>
#include "qtquick2applicationviewer.h"
#include <QtQuick/QQuickItem>
#include <QtQuick/QQuickView>
#include "shakehands.h"
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QtQuick2ApplicationViewer viewer;
viewer.setMainQmlFile(QStringLiteral("qml/shakehands/main.qml"));
QObject *rect = dynamic_cast<QObject*>(viewer.rootObject());
ShakeHands *myClass = new ShakeHands();
//=======================================//
// Init: cppGetRequest
QObject::connect(rect,
SIGNAL(qmlRequireData(QString)),
myClass,
SLOT(cppGetRequest(QString)));
QObject::connect(myClass,
SIGNAL(cppReturnAnswer(QVariant)),
rect,
SLOT(qmlUpdateData(QVariant)));
// End: cppGetRequest
//=======================================//
viewer.showExpanded();
return app.exec();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment