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 ReferenceError: Can't find variable
Forum Updated to NodeBB v4.3 + New Features

QML ReferenceError: Can't find variable

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 5.2k Views 1 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.
  • B Offline
    B Offline
    bkamps
    wrote on last edited by
    #1

    In QML I have defined some object:

    TestObject {
    model: myModel
    }

    In C++ I have set the model using setRootContext. This all works.

    Let's say in the configuration of the application there is an setting which causes the C++ myModel object not to be created and thus not binded to QML TestObject's model.

    (Ofcourse) now i get the "ReferenceError: Can' find variable: myModel.

    How to dynamicly set the model in QML?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Try:
      @
      TestObject {
      model: {
      if ((myModel != undefined) || (myModel != null))
      return myModel;
      else
      return 0;
      }
      @

      (Z(:^

      1 Reply Last reply
      0

      • Login

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