Results 1 to 4 of 4

Thread: qscript suspend function?

  1. #1
    Join Date
    Nov 2009
    Posts
    2
    Platforms
    Unix/X11 Windows

    Question qscript suspend function?

    Hello,

    is it possible to suspend a function in qscript?

    for example I have a c++ function called sleep(int ms);
    which is called from within a script function.

    and inside that c++ function I break the evaluation (save it somewhere)
    and when the time elapsed resume the script.

    Thanks in advance,
    rene

  2. #2
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qscript suspend function?

    What do you mean by "breaking the evaluation", saving it and resuming it later?

    Sure you can call a sleep function from qscript. Do you need help in calling c++ functions from qscript?

    What is your problem exactly? What do you want to achieve?

    A sleep design pattern is probably not the best solution.. You can very easily connect script code to qt signals.

    scriptcode: qtobj.signalname.connect(function SignalHandler(params) {});
    or
    scriptcode: qtobj.signalname.connect(scriptobj,scriptmethod);

    HIH

    Johannes

  3. #3
    Join Date
    Nov 2009
    Posts
    2
    Platforms
    Unix/X11 Windows

    Default Re: qscript suspend function?

    ok, the thing i'm working on is a card game.
    In the script file I have multiple functions.
    Which show some kind of animation. the animations are handled in de script like when dealing cards to the players; you see the cards moving from 1 position to the destination.
    All objects are in a QGraphicsScene.
    script is working, updates are done correctly but,

    my problem is that for example; the cards dealing function; takes about 2 seconds
    and when i call that script function from c++ it will wait till the function has ended.
    I don't want to wait there for 2 seconds; because the animations are like frame updates
    so inside the script loop for moving cards; i want to pause it for like 10ms

    at that time the script is stopped; some kind of contextmanager holds it and checks when the script must resume again.
    also the place in c++ from where the script is called will resume and no longer wait for the script to end


    it's not difficult for me to just create a pause / sleep function which is called inside the script.
    its more that while the script is running my c++ part stops executing
    I cannot put the script call in a seperate thread because I get errors accessing QGraphicsItems

    Hope my problem is more clear now.

    Thanks,
    Rene

  4. #4
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qscript suspend function?

    Yes, your problem is now well described!

    Mhh. Why don't you try to avoid that your animation blocks execution for its duration? You could use Timers and their slots, or the animation framework!

    http://doc.trolltech.com/4.6/animation-overview.html


    For bindings to qtscript for both QTimer and the QAnimation-Classes have a look at the QtScriptBindingsGenerator

    http://labs.trolltech.com/page/Proje...ript/Generator

    http://qt.gitorious.org/qt-labs/qtsc...or/commits/4.6

    Works great for me!

    Johannes

Similar Threads

  1. QScript + SimpleClass not working
    By tdt in forum Qt Programming
    Replies: 0
    Last Post: 14th February 2010, 08:25
  2. ow to suspend and resume an external application
    By josecarlosmissias in forum Newbie
    Replies: 0
    Last Post: 10th December 2009, 18:09
  3. QScript workbench in 4.3
    By jh in forum Qt Programming
    Replies: 3
    Last Post: 29th October 2009, 13:53
  4. QScript + get function call parameters
    By Fastman in forum Qt Programming
    Replies: 3
    Last Post: 1st August 2009, 15:30
  5. QVariantList from QScript?
    By musla in forum Qt Programming
    Replies: 0
    Last Post: 29th June 2009, 10:22

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.