Qt World Summit: Register Today!

QScript add a specific == operator

  • Hello !

    I am currently playing with the functionalities provided by the QScript module. I would like to evaluate a simple expression like 'val 1' == 'val 2'. Is it possible to indicate to QScript what it should use to perform the equality comparison ? In C++, I should have reimplemented the operator== for the specified types.

    Thanks a lot for your answers !

  • I honestly can't answer your question directly as I have not tried to do any operator overloading in QScript. I can say however while it is not the same thing you can extend QScript providing and registering your own functions. So you can have something in your code like:

    if( compareValue( A, B ) )
       then do something

    You'd write and register compareValue to do whatever you need. Yes yes... not operator overloading but it would world to get your comparison to work the way you want. I'm doing something like this now in my scripts.

Log in to reply