Results 1 to 3 of 3

Thread: QSA exceptions

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

    Default QSA exceptions

    When a qsa script calls a qt method, is it possible for the c++ method to throw an excepion which then can be catched by the script?

    example:

    Qt Code:
    1. // QSA Script
    2. try {
    3. ...
    4. Application.object.property = 10;
    5. ...
    6. }
    7. catch ( e ) {
    8. if (e = "some error") {
    9. // do somesthing
    10. } else {
    11. // do something else
    12. }
    13. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. // qt method
    2. MyObject::setProperty(int value)
    3. {
    4. ...
    5. if (value > 2) throw QString("some error");
    6. ...
    7. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSA exceptions

    I don't think that QSA supports exceptions at all. And Qt, in general, does not make use of C++ exceptions.

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

    Default Re: QSA exceptions

    QSA supports exceptions, and they can be detected in Qt by the QSInterpreter::hasError and errorMessage methods. There also are methods as QSInterpreter::throwError to throw an exception from Qt into QSA.

    However what I am looking for is a way to throw an error within a Qt method, where I dont know if it was called by a script or c++. So there should at least exist a way to detect within script that a called C++ method has thrown an exception. But maybe it needs QSA wrappers for every Qt class which catch the C++ exception and then do a QSInterpreter::throwError.

Similar Threads

  1. QSA: unregistered datatype 'QObjectList' for property
    By mikefilonov in forum Qt Programming
    Replies: 2
    Last Post: 9th July 2012, 08:33
  2. QSA tutorials/books
    By bouy in forum General Discussion
    Replies: 1
    Last Post: 27th February 2007, 08:11
  3. Create binaries from QSA
    By Raistlin in forum Qt Programming
    Replies: 2
    Last Post: 30th September 2006, 10:10
  4. Q_ENUMS with QSA
    By Alex in forum Qt Programming
    Replies: 0
    Last Post: 24th May 2006, 01:36
  5. Exceptions and qApp->processEvents()
    By mcostalba in forum Qt Programming
    Replies: 3
    Last Post: 8th January 2006, 17:06

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.