qmlchat.cpp Example File
chat/qmlchat.cpp
#include <QtGui/QGuiApplication>
#include <QtQuick/QQuickView>
#include <QtQml/QQmlEngine>
#include <QtQml/QQmlContext>
#include <QDebug>
#include <QBluetoothLocalDevice>
#include <QtCore/QLoggingCategory>
#ifdef Q_OS_ANDROID
#include <QtAndroidExtras/QtAndroid>
#endif
int main(int argc, char *argv[])
{
QGuiApplication application(argc, argv);
QList<QBluetoothHostInfo> infos = QBluetoothLocalDevice::allDevices();
if (infos.isEmpty())
qWarning() << "Missing Bluetooth local device. "
"Example will not work properly.";
const QString mainQmlApp = QLatin1String("qrc:/chat.qml");
QQuickView view;
#ifdef Q_OS_ANDROID
QString uuid;
if (QtAndroid::androidSdkVersion() >= 23)
uuid = QStringLiteral("c8e96402-0102-cf9c-274b-701a950fe1e8");
else
uuid = QStringLiteral("e8e10f95-1a70-4b27-9ccf-02010264e9c8");
#else
const QString uuid(QStringLiteral("e8e10f95-1a70-4b27-9ccf-02010264e9c8"));
#endif
view.engine()->rootContext()->setContextProperty(QStringLiteral("targetUuid"), uuid);
view.setSource(QUrl(mainQmlApp));
view.setResizeMode(QQuickView::SizeRootObjectToView);
QObject::connect(view.engine(), SIGNAL(quit()), qApp, SLOT(quit()));
view.setGeometry(QRect(100, 100, 360, 480));
view.show();
return application.exec();
}