Delay time in stylesheet loading
-
Hi everyone,
I made a simple application that should set a stylesheet loading settings from a file.
I put this->setStylesheet() in the MainWindow 's constructor, right after setupUI().
It happens that at first mainwindow shows itself plain, and after less than a second, modifications are applied.
This is an annoying graphic problem. -
Set the stylesheet in your main.cpp, using QApplication::setStylesheet().
-
No, I do not mean static methods. Try a more explicit QSS, like:
@
QMainWindow {
background-color:red;
}
@ -
-
Try this:
@
// in main.cpp
QTimer::singleShot(800, mainWindowPointer, SLOT(show()));
return a.exec();
@It should delay the showing of your mainWindow for 800 ms.
-
That's funny, it waits 800ms, shows the plain white window, and change the stylesheet with evident time lapse.
Even if I change the stylesheet form the UI form the effect is the same, and I forgot to say, but it's obvious, that timing differences depends on the stylesheet type, it increase for gradients for example.Mybe the sequence is that the stylesheet engine works after the show event...
-
-
[quote author="ale82" date="1390907896"]Maybe could be my PC extremly slow and this effetc emphasizes more than usual.[/quote]
This could be the case. I have seen some really heavy QSS code that took up to 4 seconds to load... but it never exhibited the behaviour you have mentioned. In my case, the whole GUI was loading in the background and once it was shown, it already had the styling applied.