Add another Component.onCompleted signal



  • Is it hard to add another stage of initialization like Component.onPreCompleted that runs entirely before the Component.onCompleted?


  • Lifetime Qt Champion

    Hi,

    What would you do in that "preCompleted" stage ? What would you consider as "pre completed" ?



  • @SGaist, preCompleted handlers should run before any of onCompleted are run, but obviously after the time when "full QML environment has been established".

    Haven't mentioned the goal (live reload): https://forum.qt.io/topic/62013/livereload-after-file-save-but-keep-some-objects because people are seemingly avoiding that topic.

    MyCppItem {
    	id: my
    	Component.onPreCompleted: LiveReloader.preserve(my, "my01")
    }
    

    MyCppItem consists of QObject shell and a pointer to the implementation object. The implementation is created by LiveReloader.preserve on the first GUI load. Unloading the GUI destroys all QObject shells but the LiveReloader is keeping the implementations. On the subsequent GUI reloads the LiveReloader.preserve installs the implementations into shells using the tags like "my01" in that example.

    The problem is if you have LiveReloader.preserve in Component.onCompleted, there is no way to execute anything else in the Component.onCompleted because the order is not specified and some implementation objects may be not yet created/installed.

    I'm investigating now the QQmlComponent::beginCreate and QQmlParserStatus::classBegin methods but they don't break the creation process in the right place. And overall the thing probably won't work as intended because other properties are evaluated initially at the same time as the Component.onCompleted properties.

    update

    Ok, now I see that it'll closer to the solution with this simpler syntax:

    MyCppItem {
    	id: my
    	liveReloadTag: "my01"
    }
    

    because the constant bindings are evaluated before everything else. Now there are conflicts with the static bindings. Is it hard to get a list of all static bindings before they are actually executed to be able to preliminary execute a part of them?


  • Lifetime Qt Champion

    It's not that people are avoiding that topic, but this forum is more user oriented and that question (as well as this one) is pretty low level. You should maybe try the interest mailing list, you'll find there Qt's developers/maintainers.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.