Unsolved QQuickWindow does not change color in the first frame
-
Hello everyone!
I have successfully changed QQuickWindow color, but get blinded by a white-color flash every time the application is run. It seems that the first frame is rendered with the old color (0:02 in the demo).
I logged the initial and after-set colors to make sure that it had been changed right after the setting. You can see the log output in the video too in the last frame.I am attaching the code here. You can also see it in the first frame of the video.
Any ideas how to make QQuickWindow displayed with the correct color in the first frame?
int app::on_run() { // Setup Qt set_qt_environment(); engine().addImportPath("qrc:/imports"); const QUrl url(u"qrc:Main/main.qml"_qs); QObject::connect( &engine(), &QQmlApplicationEngine::objectCreated, this, [url](QObject *obj, const QUrl &objUrl) { if (!obj && url == objUrl) QCoreApplication::exit(-1); }, Qt::QueuedConnection); engine().addImportPath(QCoreApplication::applicationDirPath() + "/qml"); engine().addImportPath(":/"); QQuickWindow window; LOG("Initial color: " << window.color().name().toStdString()); window.setColor(QColor("#123456")); LOG("Color after change: " << window.color().name().toStdString()); window.show(); auto ret = init(); if (ret != 0) return ret; return exec(); }
First frame: #ffffff
Second frame: #123456
Thank you for any help!
-
Why not just set background in
main.qml
? -
It gets the same result. This is a simplified example. Originally, I set it all in QML and the result is absolutely the same. I won't share that approach as it eventually comes into the same - QQuickWindow's color is changed, but the first frame contains the old color. I can't update the post anymore, so I'll add this info here:
FYI: the code in the original is the maximally simplified example. Originally, I set the color on the main window in App.qml, but the result is absolutely the same - QQuickWindow's color is changed, but the first frame contains the old color:
App.qml (another way to achieve that):
import QtQuick 6.2 import QtGUI Window { width: mainScreen.width height: mainScreen.height visible: true title: "QtGUI" color: "#123456" }
-
Also, my specs:
Qt v6.5.1, installed through Qt online installer
OS: Windows 11
Qt Creator: 10.0.2, installed through Qt online installer -
I created a bug report as it seems like a Windows-scpecific-implementation bug. I tried that on Android and it works fine there.