Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Component runtime optimization
Forum Updated to NodeBB v4.3 + New Features

Component runtime optimization

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 4 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    onek24
    wrote on last edited by
    #1

    Hello,

    does using Loaders decrease the runtime needed to create a custom Component?
    MyComponent.qml
    Without Loader:
    @import QtQuick 2.2

    MouseArea {
    width: 72
    height: 72
    Rectangle {
    anchors.fill: parent
    color: "green"
    Column {
    Text {
    text: "Test text"
    }
    ...
    }
    }
    }@
    With Loaders:
    @import QtQuick 2.2

    MouseArea {
    width: 72
    height: 72
    property Component __text: Text {
    text: "Test text"
    }
    Rectangle {
    anchors.fill: parent
    color: "green"
    Column {
    Loader {
    sourceComponent: __text
    }
    ...
    }
    }
    }@

    1 Reply Last reply
    0
    • V Offline
      V Offline
      Vincent007
      wrote on last edited by
      #2

      Did you try "QML Profiler?":http://doc-snapshot.qt-project.org/qtcreator-3.0/creator-qml-performance-monitor.html

      1 Reply Last reply
      0
      • A Offline
        A Offline
        aabc
        wrote on last edited by
        #3

        Do you need the text on startup ?

        1 Reply Last reply
        0
        • O Offline
          O Offline
          onek24
          wrote on last edited by
          #4

          [quote author="aabc" date="1397387516"]Do you need the text on startup ?[/quote]
          In that case i do need the text at startup. In such a case i will create them without a loader, but it is also posible to create it with a loader and add a splash-screen which is visible while !Loader.Ready.

          1 Reply Last reply
          0
          • J Offline
            J Offline
            Jens
            wrote on last edited by
            #5

            I think this change by itself is not very useful. Note that Loader is by default synchronous meaning it will block until the item it loads has completed. This is usually wanted behaviour because otherwise you will see it pop into existence after the initial window has been shown. In reality this means that the snippet above would be slower than not using a Loader because you are simply constructing and adding yet another item to the scene.

            You can set the asynchronous property to false on your Loader which might speed up the initial show but hardly noticeable for this particular use case. You should probably refrain from using Loader unless it is a fairly complex component you are creating as the Loader itself might be as expensive to create as a basic Text item itself.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved