Results 1 to 2 of 2

Thread: Calling object's operator+ from QtScript

  1. #1
    Join Date
    Aug 2008
    Posts
    9
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Calling object's operator+ from QtScript

    Hi Guys,

    I hope this isn't a stupid question but I'm failing to call the 'operator+' for a QVector3D from my QtScript code. Rather than adding the together the numerical values of each, it instead generates string representations and concatenates them. My code:

    var vec1 = new QVector3D(1.0,2.0,3.0);
    var vec2 = new QVector3D(4.0,5.0,6.0);
    print('Sum is ', vec1 + vec2);


    It prints "Sum is QVector3D(1, 2, 3) QVector3D(4, 5, 6)" whereas the desired result would be "Sum is QVector3D(5, 7, 9)".

    So any idea if/how I can call the operator+ forthis class from QtScript? I think there is a clue here but I don't quite get it...

    Thanks!

  2. #2
    Join Date
    Aug 2008
    Posts
    9
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Calling object's operator+ from QtScript

    Anyone?

    I guess I could subclass QVector3D and create member functions called add(), multiplyBy(), etc, but it seems like there should be a way to just use the overloaded operators...

Similar Threads

  1. Replies: 1
    Last Post: 27th February 2010, 10:33
  2. QtScript. How to add created object to script?
    By sergey_85 in forum Qt Programming
    Replies: 1
    Last Post: 18th February 2010, 14:24
  3. Replies: 7
    Last Post: 15th January 2010, 20:45
  4. Calling COM object from QT
    By mrityunjay in forum Qt Programming
    Replies: 0
    Last Post: 27th October 2009, 05:25
  5. Calling XPCOM Object from QT
    By sujith in forum Qt Programming
    Replies: 0
    Last Post: 3rd July 2009, 10:10

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.