Nominate our 2022 Qt Champions!

setContextProperty takes very long and blocks UI

  • Hey,

    I am calling "setContextProperty" with a bigger data structure. It is not extremely big (A list with about 100 entries), but it takes several seconds until the call finished.

    AND because I have to do that in the main thread, the complete UI is blocked in that time. So what can I do?


  • Hey,

    I discovered: It is not setting the data itself. It is the UI structure, that displays the data that takes so long. So I tried disabling the UI Display (It is a ListView) by setting its model to [] while I am loading. But now, re-enabling the UI Display takes long.

    What can I do?

  • Lifetime Qt Champion


    What kind of list is ?

  • It is a list of QObjects, which themself each contain a list of QObjects. But I found the error!

    The code was like this (pseudo code):

    ListView {
        model: cppData
        delegate: ListView {
            model: innerData
            delegate: Item {
                 Rectangle {...}
                 DropShadow {
                    visible: isActiveObject

    So I was creating a lot of DropShadows. Also only one was visible, that was the problem. Removing the DropShadows solved it.

Log in to reply