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

[solved] ReferenceError: Can't find variable... on MeeGo Harmattan

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 1 Posters 4.3k 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.
  • M Offline
    M Offline
    moldovan.catalin
    wrote on 14 Nov 2011, 18:22 last edited by
    #1

    I was wandering if any of you could help me with a problem I'm facing on Harmattan maybe you encountered this issue:
    I always get file:///opt/cuteBoxQml/qml/cuteBoxQml/main.qml:9: ReferenceError: Can't find variable: appModel, but works on Desktop (Windows 7)
    I have an application model class in C++ that I want to expose to QML rootContext so before setting my main QML file and I do something like this:

    @ QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create());
    GenApplicationManager *appManager = GenApplicationManager::instance();
    appManager->initialize(viewer.data());
    viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
    qDebug() << "root context before setMainQmlFile: " << viewer->rootContext();
    appManager->run(); << I set here the properties
    qDebug() << "[appModel]: " << viewer->rootContext()->contextProperty("appModel");
    viewer->setMainQmlFile(QLatin1String("qml/cuteBoxQml/main.qml"));
    viewer->showExpanded();
    qDebug() << "root context after setMainQmlFile: " << viewer->rootContext();
    qDebug() << "[appModel]: " << viewer->rootContext()->contextProperty("appModel");
    @
    In appManager->run() I set the context properties I need:

    @void GenApplicationManager::run()
    {
    qDebug() << "[GenApplicationManager::run] - set AppMgr and appModel context properties";
    _qmlViewer->rootContext()->setContextProperty("AppMgr", this);
    _qmlViewer->rootContext()->setContextProperty("appModel", _applicationModel);
    _thumbnailManager = new GenThumbnailManager(_applicationModel);
    _thumbnailManager->start();
    }@

    ...and in QML I use it like this:

    @import QtQuick 1.1
    import com.nokia.meego 1.0
    import "ui"
    PageStackWindow {
    id: appWindow
    function setInitialPage() {
    if (appModel.userToken === "" || appModel.userSecret === "")
    return Qt.resolvedUrl("ui/WelcomePage.qml")
    else
    return Qt.resolvedUrl("ui/MainPage.qml")
    }
    initialPage: setInitialPage()
    platformStyle: PageStackWindowStyle {
    background: Qt.resolvedUrl("resources/images/cute_background.png")
    backgroundFillMode: Image.PreserveAspectCrop
    }
    }@

    I used same code on Desktop (Windows 7) and MeeGo (N9), it works on Desktop flawlessly but on N9 fails with that ReferenceError.
    Any help would be appreciated.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      moldovan.catalin
      wrote on 14 Nov 2011, 20:11 last edited by
      #2

      I find out this is a known issue due to new Qt Quick application template for Meego here is the "bug report":https://bugreports.qt.nokia.com/browse/QTCREATORBUG-6490
      This "post":http://meegoharmattandev.blogspot.com/2011/11/qmlapplicationviewer-and.html gives a workaround for this issue until a fix is officially released.

      1 Reply Last reply
      0

      1/2

      14 Nov 2011, 18:22

      • Login

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