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. QQuickWindow does not change color in the first frame
QtWS25 Last Chance

QQuickWindow does not change color in the first frame

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 325 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.
  • skalexS Offline
    skalexS Offline
    skalex
    wrote on last edited by skalex
    #1

    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?

    link to the demo

    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
    First frame.png

    Second frame: #123456
    Next frame.png

    Thank you for any help!

    1 Reply Last reply
    0
    • K Offline
      K Offline
      Kamichanw
      wrote on last edited by
      #2

      Why not just set background in main.qml?

      skalexS 1 Reply Last reply
      0
      • K Kamichanw

        Why not just set background in main.qml?

        skalexS Offline
        skalexS Offline
        skalex
        wrote on last edited by skalex
        #3

        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"
        }
        
        1 Reply Last reply
        0
        • skalexS Offline
          skalexS Offline
          skalex
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • skalexS Offline
            skalexS Offline
            skalex
            wrote on last edited by
            #5

            I created a bug report as it seems like a Windows-scpecific-implementation bug. I tried that on Android and it works fine there.

            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