Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-6644

C++ signal connection to script function does work in Qt 4.6 as documented

    XMLWordPrintable

Details

    • 2efba0002d26b584c771aa9260e6d699e5ff8da3

    Description

      In http://doc.trolltech.com/4.6/scripting.html#using-signals-and-slots, there are snippets how to connect C++ signals to to script funtions. Those snippets work fine in Qt 4.5.x, but not in Qt 4.6.0. The problem seem to be in syntax how script function is defined:

      For example, the following does not work in 4.6:

      QScriptValue handler = eng.evaluate("function(text) { print('text was changed to', text); }");
      qScriptConnect(edit, SIGNAL(textChanged(const QString &)), QScriptValue(), handler);
      

      But adding the parenthesis () around the evaluated sentence, makes the example work again 4.6 (it works also in 4.5):

      QScriptValue handler = eng.evaluate("(function(text) { print('text was changed to', text); })");
      qScriptConnect(edit, SIGNAL(textChanged(const QString &)), QScriptValue(), handler);
      

      Should evaluation work without parenthesis? I assume this differenece is due to QtScript backend change to javascriptcore..

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kenthans Kent Hansen (Inactive)
            e0101981 Janne Anttila
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes