Results 1 to 3 of 3

Thread: QtScript

  1. #1
    Join Date
    Feb 2010
    Posts
    12
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Red face QtScript

    Hello,

    I'm trying to learn about qtScript. I would like to know if it is possible to use the setTimeout Javascript function.
    For that I'm creating a PushButton, connecting the onclick signal to a JS function who will call the setTimeout function, but it does not work.

    I can modify the text of the Pushbutton and connect a JS function to it. Here the code of my js file:

    button.clicked.connect(onButtonClicked);

    function onButtonClicked(checked) {
    button.text = qsTr('onClick!');
    setTimeout("timedCount()", 1000);
    }

    function timedCount()
    {
    button.text = qsTr('TimedCount!');
    }



    When I click on the button it displays the "onClick' text, but the setTimeout does not work

    Any ideas??

  2. #2
    Join Date
    Nov 2009
    Posts
    129
    Thanks
    4
    Thanked 29 Times in 29 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QtScript

    Quote Originally Posted by lamosca View Post
    I would like to know if it is possible to use the setTimeout Javascript function.
    The setTimeout function is a method of the window object in web browsers. It’s not a part of ECMAScript proper. There is a list of the objects, methods and properties QtScript supports.

    I think you could add support for a setTimeout function by using the techniques described in the Qt documentation Function Objects and Native Functions. The Context 2D Example does something like that (see its environment.cpp file).

  3. #3
    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: QtScript

    Or you can just use QTimer...
    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.


Similar Threads

  1. Replies: 0
    Last Post: 25th November 2009, 07:46
  2. QtScript Questions
    By Scorp2us in forum Qt Programming
    Replies: 9
    Last Post: 29th June 2009, 22:06
  3. QColor in QtScript
    By Kingofhearts_sri in forum Qt Programming
    Replies: 4
    Last Post: 9th June 2009, 14:50
  4. Please help with QtScript
    By Haccel in forum Qt Programming
    Replies: 0
    Last Post: 16th December 2008, 05:59
  5. QtScript
    By QTInfinity in forum Qt Programming
    Replies: 1
    Last Post: 20th November 2008, 20:10

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.