> I'm exposing a complex QGraphicsWidget to QML and the problem is, that
> whenever I load that component my application freezes for a second (on
> desktop, on mobile it's much longer).
> 
> I'd like to display a lightweight 'loading' animation and load that
> component in the background without freezing the interface. Then
> whenever it's ready it should replace the animation with the real
> content.

There is no all-encompassing answer to this. Threading is not directly provided 
in QML object instantiation (it would make simple constructions way to slow).

Firstly, do you REALLY need to do all the construction you are doing? One 
second on the desktop is an inordinately huge amount of time. Perhaps a 
different approach is needed. For example, if you loaded an entire company 
addressbook at start-up, that might be better done per-record as needed.

Can you thread the internals of your class? For example, if you did need to 
load a huge addressbook, you could do that in a thread and have a "progress" 
property and "onLoaded" signal emitted as it progresses. This keeps the 
threading in the C++ side (QThread is your friend), while using QML's inherent 
asynchronicity on the QML side. The Image elements effectively work this way 
(though the actual threading is in QDeclarativePixmap).

--
Warwick

_______________________________________________
Qt-qml mailing list
Qt-qml@trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-qml

Reply via email to