Qt WinRT app crashes when changing title bar color
-
I want to create the
WinRT
app usingQt 5.15.8
. The issue is when I add the following code to change the app title bar color:.h file
#include <winrt/Windows.System.Diagnostics.h> #include <winrt/Windows.UI.ViewManagement.h> #include <winrt/Windows.Foundation.h> using namespace winrt; using namespace Windows::System::Diagnostics; using namespace Windows::UI; using namespace Windows::UI::ViewManagement; using namespace Windows::Foundation;
.cpp file:
auto titleBar = ApplicationView::GetForCurrentView().TitleBar(); titleBar.BackgroundColor(ColorHelper::FromArgb(255, 54, 60, 116)); titleBar.ForegroundColor(ColorHelper::FromArgb(255, 232, 211, 162));
The program just exits (crashes).
I run the debugger but it still the same, the app just exits. It's a simple app, can someone reproduce this issue?Dialog::Dialog(QWidget *parent) : QDialog(parent) { QPushButton *btn = new QPushButton("Click", this); btn->setGeometry(250, 400, 100, 100); connect(btn, &QPushButton::clicked, [this]() { ApplicationView appView = ApplicationView::GetForCurrentView(); if (appView) { qDebug() << "Success!"; auto titleBar = appView.TitleBar(); titleBar.BackgroundColor(ColorHelper::FromArgb(255, 54, 60, 116)); titleBar.ForegroundColor(ColorHelper::FromArgb(255, 232, 211, 162)); } else { qDebug() << "Failed!!!"; } }); }
I have Windows 10 Version 22H2 installed. Developer mode is enabled. It just exits whithout any return from
ApplicationView
instance.Screenshot:
https://i.ibb.co/cbRzxHB/Qt-Win-RT-app-issue.gif17:37:53: Starting C:/Qt/5.15.8/winrt_x86_msvc2019/bin/winrtrunner.exe "C:\Users\cobra\Documents\Projects\UWP\build-TestUWP23-Desktop_Qt_UWP_5_15_8_MSVC2019_32bit-Debug\debug\TestUWP23.exe" --install --verbose... qt.winrtrunner: Using the Appx profile. qt.winrtrunner: Package already installed. qt.winrtrunner: App started with process ID 11952 qt.winrtrunner: Unable to sendFile: Cannot open C:\Users\cobra\AppData\Local\Packages\066dc9bf-27bd-4f3e-abbc-06652d5ce6ce_qqv8ky19h7t4c\LocalState\TestUWP23_output.txt for input qt.winrtrunner: Unable to copy test output file "C:\Users\cobra\AppData\Local\Packages\066dc9bf-27bd-4f3e-abbc-06652d5ce6ce_qqv8ky19h7t4c\LocalState\TestUWP23_output.txt" to local file "TestUWP23_output.txt". 17:37:58: C:/Qt/5.15.8/winrt_x86_msvc2019/bin/winrtrunner.exe exited with code 9
Any ideas why this code leads to such issue? Thank you.