Results 1 to 4 of 4

Thread: My own print function in Qt Script

  1. #1
    Join Date
    Feb 2009
    Posts
    20

    Default My own print function in Qt Script

    I dont know why, but nothing is printed to my QtScript Debugger console, does anybody know why?
    Qt Code:
    1. QScriptValue Debug_Function(QScriptContext *ctx, QScriptEngine *)
    2. {
    3. QString result;
    4. for (int i = 0; i < ctx->argumentCount(); ++i)
    5. {
    6. if (i != 0)
    7. result.append(QLatin1String(" "));
    8.  
    9. QString s = ctx->argument(i).toString();
    10. if (ctx->state() == QScriptContext::ExceptionState)
    11. break;
    12. result.append(s);
    13. }
    14. return ctx->engine()->toScriptValue(result);
    15. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. QScriptValue dfunc = engine.newFunction(Debug_Function);
    2.  
    3. engine.globalObject().setProperty("debug", dfunc);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Posts
    132
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: My own print function in Qt Script

    How about this:
    Qt Code:
    1. QScriptValue Debug_Function(QScriptContext *ctx, QScriptEngine *)
    2. {
    3. QString result;
    4. for (int i = 0; i < ctx->argumentCount(); ++i)
    5. {
    6. if (i != 0)
    7. result.append(QLatin1String(" "));
    8.  
    9. QString s = ctx->argument(i).toString();
    10. if (ctx->state() == QScriptContext::ExceptionState)
    11. break;
    12. result.append(s);
    13. }
    14. qDebug() << result;
    15. return ctx->engine()->toScriptValue(result);
    16. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Feb 2009
    Posts
    20

    Default Re: My own print function in Qt Script

    that doesn't work. I did not see the result string in the Qt Script Debugger "Debug Output" widget.

  4. #4
    Join Date
    Jan 2006
    Posts
    132
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: My own print function in Qt Script

    Well the term "debug output" is missleading, actually it does not display debug output but:

    The debug output widget shows messages generated by the print() script function. Scripts can use the special variables __FILE__ and __LINE__ to include the current location information in the messages.
    So either just use print, or hack the debugger to also redirect debug output to that window.

Similar Threads

  1. QPSQL problem
    By LoneWolf in forum Installation and Deployment
    Replies: 60
    Last Post: 4th November 2009, 14:22
  2. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 12:57
  3. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 17:33
  4. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.