Results 1 to 7 of 7

Thread: how to call user defined function of user defined call from QtScriptEngine evaluate

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Re: how to call user defined function of user defined call from QtScriptEngine evalua

    string variable result shows a message " rectangle.drawr[undefined] is not a function"

  2. #2
    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: how to call user defined function of user defined call from QtScriptEngine evalua

    This works fine for me:

    Qt Code:
    1. #include <QApplication>
    2. #include <QScriptEngine>
    3. #include <QtDebug>
    4.  
    5. class RItem : public QObject {
    6. Q_OBJECT
    7. public:
    8. RItem() : QObject() {}
    9. public slots:
    10. void drawr() { qDebug() << Q_FUNC_INFO; }
    11. };
    12.  
    13. #include "main.moc"
    14.  
    15. int main(int argc, char **argv) {
    16. QApplication app(argc, argv);
    17. QScriptEngine engine;
    18. RItem item;
    19. QScriptValue val = engine.newQObject(&item);
    20. engine.globalObject().setProperty("rectangle", val);
    21. engine.evaluate("rectangle.drawr()") ;
    22. return 0;
    23. }
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3

    Default Re: how to call user defined function of user defined call from QtScriptEngine evalua

    Thanks a lot. I declared slot as private that's why it was not working for me.

Similar Threads

  1. How to get user-defined message?
    By ponponfish in forum Qt Programming
    Replies: 3
    Last Post: 17th May 2011, 16:19
  2. QSqlQueryModel + user defined roles
    By NoRulez in forum Qt Programming
    Replies: 1
    Last Post: 7th December 2009, 07:29
  3. Resizing user defined QGraphicsItem
    By manti_madhu in forum Qt Programming
    Replies: 0
    Last Post: 9th September 2009, 09:35
  4. Using User Defined Libraries
    By csvivek in forum Qt Programming
    Replies: 1
    Last Post: 27th May 2008, 19:47
  5. User Defined Signal?
    By rajeshs in forum Newbie
    Replies: 2
    Last Post: 18th December 2007, 11:42

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.