Results 1 to 4 of 4

Thread: [QtScript] One getter/setter function for multiple properties

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2008
    Posts
    35
    Thanks
    7
    Thanked 3 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default [QtScript] One getter/setter function for multiple properties

    What I am looking for is something like this:
    Qt Code:
    1. QScriptValue getter(QScriptContext* context, QScriptEngine* engine)
    2. {
    3. QString property = context->getProperty(); // this is what I am looking for
    4. if(property == "id")
    5. return id;
    6. else if(property == "name")
    7. return name;
    8. else if
    9. context->throwError("There is no property like that!");
    10. }
    To copy to clipboard, switch view to plain text mode 
    And so you could just do this:
    Qt Code:
    1. object.setProperty("id", engine.newFunction(getter), QScriptValue::PropertyGetter);
    2. object.setProperty("name", engine.newFunction(getter), QScriptValue::PropertyGetter);
    To copy to clipboard, switch view to plain text mode 
    So that you only have to make one getter for two properties.

    I hope you understand what I mean!
    Gillis
    Last edited by supergillis; 21st May 2009 at 12:37.

Similar Threads

  1. QPSQL problem
    By LoneWolf in forum Installation and Deployment
    Replies: 60
    Last Post: 4th November 2009, 14:22
  2. Regading Driver to connect Postgresql Database
    By dummystories in forum Installation and Deployment
    Replies: 38
    Last Post: 12th March 2009, 07:19
  3. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 12:57
  4. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 17:33
  5. 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.