Answer the question
In order to leave comments, you need to log in
How to force the qml component to update during long calculations?
Greetings!
I interact with qml from c++.
In general, in qml I want to change some property of the component before long calculations, for example, the color of the Rectangle.
So with setProperty("color", "red"); the color changes only after the assurance of long calculations.
If they are removed of course everything is ok.
I repeat, I change the property from the side of c ++ and not inside qml.
Those. The interface seems to hang for a while.
For example, code:
engine.rootObjects().at(0)->findChild<QObject*>("myRect")->setProperty("color", "red");
qlonglong l = 1;
while (l<1000000000000) {
l+=1;
}
Answer the question
In order to leave comments, you need to log in
Долгие вычисления всегда следует запускать в отдельном потоке.
В вашем случае, например через
doc.qt.io/qt-5.5/qtconcurrentrun.html
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question