Results 1 to 4 of 4

Thread: Using Javascript in Qt

  1. #1
    Join Date
    Jan 2013
    Posts
    23
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Using Javascript in Qt

    Is it possible to use javascript functions in my Qt desktop project?
    If yes, can you show some example like how can I define function?
    I always find QML examples on the net but my project is a desktop project.
    Last edited by sipahi; 31st January 2013 at 10:22.

  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: Using Javascript in Qt

    Quote Originally Posted by sipahi View Post
    Is it possible to use javascript functions in my Qt desktop project?
    Yes.
    If yes, can you show some example like how can I define function?
    Qt Code:
    1. QScriptEngine engine;
    2. //...
    3. QScriptValue fun = engine.evaluate("(function() { return 7; })");
    4. // ...
    5.  
    6. int retVal = 0;
    7. if(fun.isFunction()) {
    8. retVal = fun.call().toInt32();
    9. }
    To copy to clipboard, switch view to plain text mode 
    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 2013
    Posts
    23
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Using Javascript in Qt

    thank you for your answer @wysota.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Using Javascript in Qt

    Qt Documentation has a couple of examples around the topic of using QtScript
    http://qt-project.org/doc/qt-4.8/examples-script.html

    Cheers,
    _

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

    sipahi (31st January 2013)

Similar Threads

  1. How to get javascript var value in qt
    By ram4soft in forum Qt Programming
    Replies: 0
    Last Post: 12th April 2011, 15:55
  2. Help with QML, JavaScript and C++
    By chetu1984 in forum Qt Quick
    Replies: 5
    Last Post: 14th February 2011, 22:42
  3. Replies: 9
    Last Post: 29th November 2010, 12:12
  4. Javascript
    By ale301168 in forum Qt Programming
    Replies: 0
    Last Post: 6th September 2008, 23:23
  5. JavaScript in QTextBrowser
    By manojmka in forum Qt Programming
    Replies: 4
    Last Post: 27th December 2007, 08: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.