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

Cannot access dynamic properties from QJSEngine

    Details

    • Commits:
      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

          For Gerrit Dashboard: QTBUG-38181
          # Subject Branch Project Status CR V

            Activity

              People

              • Assignee:
                mitch_curtis Mitch Curtis
                Reporter:
                cmannett85 Cam Mannett
              • Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes