Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. qml engine problems
Forum Updated to NodeBB v4.3 + New Features

qml engine problems

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 521 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • rodriguezamador90R Offline
    rodriguezamador90R Offline
    rodriguezamador90
    wrote on last edited by
    #1

    Hello guys.

    I have the following problem:

    class App: public QObject
    {
    // app methods
    }

    and other class

    class MobileApp: public App{

    Q_INVOKABLE void method1();

    }

    in the main.cpp do:

    MobileApplicationUI mApp;
    // from QML we have access to App as mApp
    QQmlContext* context = engine.rootContext();
    context->setContextProperty("mApp", &mApp);

    and when I make the call to mApp.method1() qml engine return the next error:

    TypeError: Property 'method1' of object App(0xa2c0646c) is not a function

    Thanks

    sierdzioS 1 Reply Last reply
    0
    • rodriguezamador90R rodriguezamador90

      Hello guys.

      I have the following problem:

      class App: public QObject
      {
      // app methods
      }

      and other class

      class MobileApp: public App{

      Q_INVOKABLE void method1();

      }

      in the main.cpp do:

      MobileApplicationUI mApp;
      // from QML we have access to App as mApp
      QQmlContext* context = engine.rootContext();
      context->setContextProperty("mApp", &mApp);

      and when I make the call to mApp.method1() qml engine return the next error:

      TypeError: Property 'method1' of object App(0xa2c0646c) is not a function

      Thanks

      sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      @rodriguezamador90 said in qml engine problems:

      QQmlContext* context = engine.rootContext();
      context->setContextProperty("mApp", &mApp);

      It's important to call this method before you set QML source file on the engine. So make sure you call it before calling engine.load("main.qml").

      (Z(:^

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved