← Back to team overview

ubuntu-phone team mailing list archive

Re: Running QML functions in parallel thread

 

This is my code that creates buttons field:

onCreateField:
{
    for(var i=0;i<fieldWidth;i++)
    {
        for(var j=0;j<fieldHeight;j++)
        {
            createButton(i, j);
        }
    }
}

function createButton(x, y)
{
    __buttonX = x;
    __buttonY = y;

    __component = Qt.createComponent("GameButton.qml");

    if(__component != null)
        continueButtonCreation();
    else
        __component.ready.connect(continueButtonCreation);
}

function continueButtonCreation()
{
    var button = __component.createObject(field, {"row": __buttonY,
"column": __buttonX});

     if (button == null) {
         // Error Handling
         console.log("Error creating object");

         return;
     }

     updateValveState.connect(button.stateUpdated);
     button.buttonClicked.connect(buttonClicked);

     field.clearField.connect(button.release);
}


fieldWidth = fieldHeight = 16;


2013/4/16 Alex Tyler <alex.tyler@xxxxxxxxxx>

> Can we see some code? The only time Images hang for me in QML is when it's
> trying to load them synchronously. Try setting asynchronous to true.
>
> Cheers,
> Alex
>
> On Tue, Apr 16, 2013 at 10:20 AM, <mrqtros@xxxxxxxxx> wrote:
>
>>  I thought Nick creates 1024 (16x16) buttons, lol =) And even did not
>> thought - for what :D
>>
>> Of course code is extremely bad, if buttons with size 16x16 pixels
>> creating slowly.
>>
>> 16.04.13 12:09 Michael Zanetti написал(а):
>>  On Tuesday 16 April 2013 01:01:28 Николай Шатохин wrote:
>> > Hello.
>> >
>> > In my code I'm creating 16x16 buttons in cycle and this take few
>> seconds.
>> > While function that creating buttons runs, app freezes. I want to show
>> > loading animation while this function runs. So, how to run this
>> function in
>> > parallel thread to avoid freezing?
>> >
>> > Best regards,
>> > Nick
>>
>>  Creating 16x16 buttons shouldn take a few seconds. Can you paste the
>> code
>> (also the button itself). To me it seems the issue is somewhere else,
>> e.g. in
>> the way you create the buttons or the buttens themselves are very slow.
>>
>>  Br,
>> Michael
>>
>> --
>>  Mailing list: https://launchpad.net/~ubuntu-phone
>> Post to : ubuntu-phone@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~ubuntu-phone
>> More help : https://launchpad.net/~ubuntu-phone
>>
>>
>>
>> --
>> Mailing list: https://launchpad.net/~ubuntu-phone
>> Post to     : ubuntu-phone@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~ubuntu-phone
>> More help   : https://help.launchpad.net/ListHelp
>>
>>
>

Follow ups

References