Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-81038

Provide Component.onPreCompleted attached signal emitted before object completion state

    XMLWordPrintable

Details

    Description

      Component's completed signal is emitted after the object has been instantiated and full QML environment has been established. The signal is often used to execute script code when declarative approach isn't suitable for a reason or another. The signal is a bit overloaded since the completed state is also used to execute costly operations inside Qt Quick elements to avoid doing unnecessary intermediate work until all the bindings have been evaluated and the system can be reasonably certain the property value assigned to the objects are close to the wanted configuration.

      I haven't looked at Component construction code internals lately, but according the documentation the order of running the onCompleted handlers is undefined so there is no guarantees that the script code defined in onCompleted signal handler will actually execute before the heavy operations. If the script changes object property state (geometry, source to be loaded, text to be layout) there is a risk that heavy operations will get executed twice. Ideally the system would also provide preCompleted signal that would be emitted after full QML environment has been established but just before objects reach the completed state.

      Note this is just a suggestion, proper evaluation, possibly profiling would be needed to make sure if the new signal provides value, e.g. the discussed performance benefits. It is also not hard to imagine emitting signals before component completion can cause unforeseen issues.

      Didn't found duplicate reports here, but found one forum discussion from 2015 also asking for such a signal, apparently needed for a QML live reload feature https://forum.qt.io/topic/62100/add-another-component-oncompleted-signal/4

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qtqmlteam Qt Qml Team User
            jpetrell Joona Petrell
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes