Results 1 to 5 of 5

Thread: Does Qt cache ECMAScripted QML values?

  1. #1
    Join Date
    Jan 2012
    Posts
    3
    Thanks
    1
    Platforms
    Windows

    Default Does Qt cache ECMAScripted QML values?

    Hi.

    This question might be a bit of a long shot, but.. I'm writing some GUI classes in Java that use a similar system to Qt where properties can be scripted. For example, I can set the position of a Widget to be based on the size of itself or a parent Widget, by exposing the Widget object(s) to the scripting language. Here's an example (JSON & JavaScript):
    Qt Code:
    1. "offset" : {
    2. "x" : "-(me.getSize().getX() / 2)",
    3. "y" : "-(me.getSize().getY() / 2)"
    4. },
    To copy to clipboard, switch view to plain text mode 
    I noticed that calling the script every frame is really slow - the FPS goes from ~3000 to ~150. I have thought about various ways to cache the values of the properties that are scripted, but the solution always involves having some kind of listeners that observe the values held by the objects that the scripts rely on, which I think will end up really messy.

    So, I'm wondering if Qt does anything in terms of caching the result of scripted QML properties? I know C++ is different to Java in terms of performance, but I thought I'd ask anyway.

    Cheers.
    Last edited by wysota; 28th January 2012 at 12:30.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Does Qt cache ECMAScripted QML values?

    Values are just values, they are cached by definition. What Qt Quick does is that it monitors changes to properties that are part of expressions bound (not assigned, that's the crucial difference) to another property. So it recalculates them only when they really change. This is not inherent to ECMAScript but specifically to property binding features of Qt Quick.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2012
    Posts
    3
    Thanks
    1
    Platforms
    Windows

    Default Re: Does Qt cache ECMAScripted QML values?

    Quote Originally Posted by wysota View Post
    Values are just values, they are cached by definition. What Qt Quick does is that it monitors changes to properties that are part of expressions bound (not assigned, that's the crucial difference) to another property. So it recalculates them only when they really change. This is not inherent to ECMAScript but specifically to property binding features of Qt Quick.
    Ah, yes, I should have said expressions not values. Can you share any insight on how it monitors the changes and how it determines which properties to monitor?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Does Qt cache ECMAScripted QML values?

    As far as I know (I might be wrong) each property has a Qt signal associated with it that fires each time the value changes. So it boils down to listening to those signals and reacting upon them (e.g. by requesting a recalculation next time the value is read).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. The following user says thank you to wysota for this useful post:

    crumbs (29th January 2012)

  6. #5
    Join Date
    Jan 2012
    Posts
    3
    Thanks
    1
    Platforms
    Windows

    Default Re: Does Qt cache ECMAScripted QML values?

    Quote Originally Posted by wysota View Post
    As far as I know (I might be wrong) each property has a Qt signal associated with it that fires each time the value changes. So it boils down to listening to those signals and reacting upon them (e.g. by requesting a recalculation next time the value is read).
    Thank you, wysota.

Similar Threads

  1. Replies: 0
    Last Post: 31st July 2010, 17:27
  2. Replies: 3
    Last Post: 12th May 2010, 13:11
  3. slowness QGraphicsView setScene
    By rk123 in forum Qt Programming
    Replies: 4
    Last Post: 1st April 2010, 18:22
  4. Can Qt handle pdf documents???
    By webquinty in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 23rd March 2009, 15:16
  5. How to Handle new Qt?
    By ashukla in forum General Programming
    Replies: 3
    Last Post: 3rd March 2008, 11:50

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.