summaryrefslogtreecommitdiffstats
path: root/tradeshow/iot-sensortag/main.cpp
diff options
context:
space:
mode:
authorMaurice Kalinowski <maurice.kalinowski@qt.io>2017-09-27 13:06:15 +0200
committerMaurice Kalinowski <maurice.kalinowski@qt.io>2017-10-04 08:14:40 +0000
commitba42ff33c9d84bf8da482e673f61e9d1de33e1a3 (patch)
tree4d6b8240616206a96852c4a3f67ec784d296cb91 /tradeshow/iot-sensortag/main.cpp
parentd53a691180070e8126c24fae2115cb7afd867a94 (diff)
iot-sensortag: Add logging window
This is most useful in the embedded use-case. Usually there is no debug connection and initialization of a bluetooth connection can take very long. Change-Id: If5b6e8a6e684d2340d6a52b8b21bec25630d6874 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'tradeshow/iot-sensortag/main.cpp')
-rw-r--r--tradeshow/iot-sensortag/main.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/tradeshow/iot-sensortag/main.cpp b/tradeshow/iot-sensortag/main.cpp
index 5dd9a7e..ba5324b 100644
--- a/tradeshow/iot-sensortag/main.cpp
+++ b/tradeshow/iot-sensortag/main.cpp
@@ -78,8 +78,22 @@
Q_DECLARE_LOGGING_CATEGORY(boot2QtDemos)
Q_LOGGING_CATEGORY(boot2QtDemos, "boot2qt.demos.iot")
+QString loggingOutput;
+QQuickWindow *loggingItem{nullptr};
+void handleMessageOutput(QtMsgType, const QMessageLogContext &, const QString &text)
+{
+ loggingOutput.prepend("\n");
+ loggingOutput.prepend(text);
+
+ loggingOutput.chop(loggingOutput.size() - 1024);
+ if (loggingItem)
+ loggingItem->setProperty("loggingOutput", loggingOutput);
+}
+
int main(int argc, char *argv[])
{
+ auto oldHandler = qInstallMessageHandler(handleMessageOutput);
+
// QtChars mandate using QApplication as it uses the graphics view fw
QApplication app(argc, argv);
@@ -184,9 +198,12 @@ int main(int argc, char *argv[])
item->setProperty("contentFile", mainFile);
item->setProperty("seriesStorage", QVariant::fromValue(&seriesStorage));
item->setProperty("addresses", addressString);
+ loggingItem = item;
}
int returnValue = app.exec();
remoteProviderPool->stopScanning();
+ qInstallMessageHandler(oldHandler);
+
return returnValue;
}