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

Cannot access dynamic properties from QJSEngine

    XMLWordPrintable

Details

    • 08569a0981308f2d3c164d89aa4a00f321fd8e21

    Description

      QScriptEngine allows me to access dynamic properties, but QJSEngine does not - I would expect them to be the same.

      int main( int argc, char* argv[] )
      {
          QCoreApplication app( argc, argv );
      
          {
              auto myObject = new QObject();
              myObject->setProperty( "myProp", 42 );
      
              QScriptEngine engine;
      
              auto scriptMyObject = engine.newQObject( myObject );
              engine.globalObject().setProperty( "myObject", scriptMyObject );
      
              cout << engine.evaluate( "myObject.myProp" ).toInt32() << endl;
          }
      
          {
              auto myObject = new QObject();
              myObject->setProperty( "myProp", 42 );
      
              QJSEngine engine;
      
              auto scriptMyObject = engine.newQObject( myObject );
              engine.globalObject().setProperty( "myObject", scriptMyObject );
      
              cout << engine.evaluate( "myObject.myProp" ).toInt() << endl;
          }
      
          return EXIT_SUCCESS;
      }
      

      Returns:

      42
      0
      

      Attachments

        Issue Links

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

          Activity

            People

              mitch_curtis Mitch Curtis
              cmannett85 Cam Mannett
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes