summaryrefslogtreecommitdiffstats
path: root/examples/vulkan/hellovulkanwidget/main.cpp
diff options
context:
space:
mode:
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);