Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt WinRT app crashes when changing title bar color
Forum Updated to NodeBB v4.3 + New Features

Qt WinRT app crashes when changing title bar color

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 145 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Cobra91151C Offline
    Cobra91151C Offline
    Cobra91151
    wrote on last edited by
    #1

    I want to create the WinRT app using Qt 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.gif

    17: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.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved