Results 1 to 2 of 2

Thread: Accessing QtScript arrays from C++

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Jul 2009
    Posts
    139
    Thanks
    13
    Thanked 59 Times in 52 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Accessing QtScript arrays from C++

    Works for me. Can you post your code?
    Qt Code:
    1. #include <QtGui>
    2. #include <QtScript>
    3.  
    4. int main(int argc, char * argv[])
    5. {
    6. QApplication a(argc, argv);
    7. QScriptEngine eng;
    8. QScriptValue val = eng.evaluate("[1, 2, 3, 'four', 'five']");
    9.  
    10. qDebug() << val.isArray();
    11.  
    12. QVariantList arr = val.toVariant().toList();
    13.  
    14. foreach (QVariant item, arr)
    15. {
    16. qDebug() << item;
    17. }
    18.  
    19. return 0;
    20. }
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to numbat for this useful post:

    wookoon (8th June 2010)

Similar Threads

  1. Replies: 0
    Last Post: 25th November 2009, 07:46
  2. debugging arrays
    By divide in forum Qt Tools
    Replies: 1
    Last Post: 12th October 2009, 21:17
  3. Accessing array in both C++ and QtScript
    By abernat in forum Qt Programming
    Replies: 10
    Last Post: 6th September 2009, 22:21
  4. QtScript and arrays
    By supergillis in forum Qt Programming
    Replies: 1
    Last Post: 20th May 2009, 19:13
  5. creating 2-d arrays
    By therealjag in forum Newbie
    Replies: 1
    Last Post: 21st February 2006, 17:41

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
  •  
Qt is a trademark of The Qt Company.