summaryrefslogtreecommitdiffstats
path: root/examples/vulkan/hellovulkanwidget/main.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2017-03-30 09:43:07 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2017-03-30 15:04:12 +0000
commit4fd5273f6144f25d675c733e83c3137ee3921aef (patch)
tree6a3410a8b0b7a0dd3e5bbbc39623577cfdef927e /examples/vulkan/hellovulkanwidget/main.cpp
parent2cc1ff3bc2a247ada8fb62f37613d763fb664cf0 (diff)
hellovulkanwidget example: Add a widget showing debug output
Add a tab widget for vulkan info and debug log. Change-Id: I0428bb5b6f847d0e94d62e846d34e4cb69eda5b6 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'examples/vulkan/hellovulkanwidget/main.cpp')
-rw-r--r--examples/vulkan/hellovulkanwidget/main.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/examples/vulkan/hellovulkanwidget/main.cpp b/examples/vulkan/hellovulkanwidget/main.cpp
index 320e015e67..5ddaf90224 100644
--- a/examples/vulkan/hellovulkanwidget/main.cpp
+++ b/examples/vulkan/hellovulkanwidget/main.cpp
@@ -49,16 +49,35 @@
****************************************************************************/
#include <QApplication>
+#include <QPlainTextEdit>
#include <QVulkanInstance>
+#include <QLibraryInfo>
#include <QLoggingCategory>
+#include <QPointer>
#include "hellovulkanwidget.h"
Q_LOGGING_CATEGORY(lcVk, "qt.vulkan")
+static QPointer<QPlainTextEdit> messageLogWidget;
+static QtMessageHandler oldMessageHandler = nullptr;
+
+static void messageHandler(QtMsgType msgType, const QMessageLogContext &logContext, const QString &text)
+{
+ if (!messageLogWidget.isNull())
+ messageLogWidget->appendPlainText(text);
+ if (oldMessageHandler)
+ oldMessageHandler(msgType, logContext, text);
+}
+
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
+ messageLogWidget = new QPlainTextEdit(QLatin1String(QLibraryInfo::build()) + QLatin1Char('\n'));
+ messageLogWidget->setReadOnly(true);
+
+ oldMessageHandler = qInstallMessageHandler(messageHandler);
+
QLoggingCategory::setFilterRules(QStringLiteral("qt.vulkan=true"));
QVulkanInstance inst;
@@ -82,7 +101,7 @@ int main(int argc, char *argv[])
VulkanWindow *vulkanWindow = new VulkanWindow;
vulkanWindow->setVulkanInstance(&inst);
- MainWindow mainWindow(vulkanWindow);
+ MainWindow mainWindow(vulkanWindow, messageLogWidget.data());
QObject::connect(vulkanWindow, &VulkanWindow::vulkanInfoReceived, &mainWindow, &MainWindow::onVulkanInfoReceived);
QObject::connect(vulkanWindow, &VulkanWindow::frameQueued, &mainWindow, &MainWindow::onFrameQueued);