Hello Curtis,
looking at the documentation, I would suggest to create a subclass of 
QQmlIncubator and implent the statusChanged method with you code to execute 
when the object is ready.

http://doc.qt.io/qt-5/qqmlincubator.html#statusChanged

>From the documentation, it will be called whenever the status change and the 
>default implementation do nothing. So, it’s really seems that has been put 
>exactly for your purpose.

Ciao,
Gianluca.


Il giorno 25/nov/2015, alle ore 21:59, Curtis Mitch 
<mitch.cur...@theqtcompany.com> ha scritto:

> 
> Hi.
> 
> I'm playing around with a project that requires asynchronous loading of 
> QQuickItems. Specifically, each item has some basic visuals, and some Box2D 
> types to construct. The items should be loaded asynchronously as there will 
> be a large amount of them, and they should only be loaded when the view is 
> close by (the items are within a Flickable).
> 
> I thought I'd use QQmlIncubator for this. Having never used it before, I went 
> to the detailed description [1] to find an example:
> 
> QQmlIncubator incubator;
> component->create(incubator);
> 
> while (incubator.isReady()) {
>    QCoreApplication::processEvents(QEventLoop::AllEvents, 50);
> }
> 
> QObject *object = incubator.object();
> 
> My first thought is that the "Performance Considerations And Suggestions" 
> documentation [2] explicitly suggests against such code, saying things like:
> 
> "never manually spin the event loop"
> 
> and:
> 
> "Note: A pattern which is tempting, but should never be used, is creating 
> your own QEventLoop or calling QCoreApplication::processEvents() in order to 
> avoid blocking within a C++ code block invoked from QML. This is dangerous, 
> because when an event loop is entered in a signal handler or binding, the QML 
> engine continues to run other bindings, animations, transitions, etc. Those 
> bindings can then cause side effects which, for example, destroy the 
> hierarchy containing your event loop."
> 
> I'd rather not have to handle all this stuff myself, if possible.
> 
> So, is there a way to asynchronously create Qt Quick Items from a 
> QQmlComponent (without using Loader), without having to write my own 
> incubator? Or have I misunderstood the point of QQmlIncubator?
> 
> The reason why I want to avoid Loader is that, from my experience with Qt 
> Quick Controls, it doesn't perform so well with a large number of items.
> 
> Cheers.
> 
> [1] http://doc.qt.io/qt-5/qqmlincubator.html#details
> [2] http://doc.qt.io/qt-5/qtquick-performance.html#timing-considerations
> _______________________________________________
> Interest mailing list
> Interest@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to