Results 1 to 5 of 5

Thread: QtScript : passing array as argument into function

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QtScript : passing array as argument into function

    You can provide get/set methods for the class.

  2. #2
    Join Date
    Sep 2007
    Location
    Vancouver B.C., Canada
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QtScript : passing array as argument into function

    Quote Originally Posted by wysota View Post
    You can provide get/set methods for the class.
    Sorry I should have given a bit more detail, I currently have get/set methods to allow me to get/set elements in the QByteArray however I was trying to find a way to provide 'operator[]' functionality in the script.

    Currently I have this:

    Qt Code:
    1. function test(arg) {
    2. print("arg[0] = " + arg.getAt(0) + "\n");
    3. arg.setAt(0,123);
    4. }
    To copy to clipboard, switch view to plain text mode 

    What I'm trying to achieve is this:

    Qt Code:
    1. function test(arg) {
    2. print("arg[0] = " + arg[0] + "\n");
    3. arg[0] = 123;
    4. }
    To copy to clipboard, switch view to plain text mode 

    Is the latter possible with QtScript?


    Derek R.

  3. #3
    Join Date
    Sep 2007
    Location
    Vancouver B.C., Canada
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QtScript : passing array as argument into function

    I still haven't been able to find a solution to the operator[] question so I've just been doing tests using my set/get methods for array access.

    The problem I'm running into now is the speed of accessing the array, just a relatively small array size of 100000 entries takes ~3s to iterate through and set.

    I was expecting maybe a few orders of magnitude difference in speed (versus normal C++ execution), however this is more like several orders of magnitude difference. Is there any way to speed this up, or a different way to pass in and modify a byte array in a script function?

    Derek R.

Similar Threads

  1. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  2. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52

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.