I would like to know if it's possible to load stylesheets a lot faster than using my method in a Qt app.
Here my codes:
this->setStyleSheet("background-color : black;");
Took 270 ms to execute this simple css/qss styling.
With a lot bigger qss styling using this import method
QFile file("style.qss");
if(!file.open(QFile::ReadOnly)){
qDebug() << "Style QSS file not found";
}
css = QString::fromLatin1(file.readAll());
file.close();
this command
this->setStyleSheet(css);
took 330ms so it's not that bad considering the difference of css styling blocks executed.
So it looks like the init of the setStyleShet command is very long. My question is: Is there a way of speeding up this command (by not using Qstring, other import methods,....) or by threading ?
For me it's huge because I need to update often my stylesheets and it's taking as much time as all my logic executed.
Thanks. Have a nice day :)
Found this method :
this->style()->unpolish(this); //"this" is my main window
this->style()->polish(this);
this->update();
instead of :
this->setStyleSheet(css);
It's incredibly fast ! (0-1 ms vs 150-200ms)
Solution was there: http://qt-project.org/doc/qt-4.8/stylesheet-syntax.html#note-233
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With