Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9123311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:18:30+00:00 2026-06-17T06:18:30+00:00

The following code the constructor loads up a Qml file that loads data from

  • 0

The following code the constructor loads up a Qml file that loads data from a remote Json data source and this works perfectly fine. When I call the startMenu method I am using the exact same Qml in MainMenu.Qml but as soon as I call dataSource.load() my application crashes at QDeclarativeExpression::hasError (), after which it just hangs. There are no error messages or exceptions being emitted.

If I move the dataSource.load(); to a button click it works, but then I have no way to load my data when the page loads.

#include "MyAppBB.hpp"

#include <bb/cascades/Application>
#include <bb/cascades/QmlDocument>
#include <bb/cascades/AbstractPane>
#include <bb/cascades/Button>
#include <bb/data/DataSource>
#include <wifi/wifi_service.h>

using namespace bb::cascades;

MyAppBB::MyAppBB(bb::cascades::Application *app) :
        QObject(app) {
    // create scene document from main.qml asset
    // set parent to created document to ensure it exists for the whole application lifetime
    bb::data::DataSource::registerQmlTypes();
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    this->myApp = app;

    QDeclarativePropertyMap* propertyMap = new QDeclarativePropertyMap;
    propertyMap->insert("name", QVariant(QString("Wes Barichak")));
    propertyMap->insert("phone", QVariant(QString("519-555-0199")));

    // create root object for the UI
    this->root = qml->createRootObject<AbstractPane>();

    qml->setContextProperty("propertyMap", propertyMap);
    qml->setContextProperty("root", this);

    QObject *newButton = root->findChild<QObject*>("btnLogin");
    QObject::connect(newButton, SIGNAL(clicked()), this, SLOT(loginClick()));
    // set created root object as a scene
    app->setScene(root);
}

void MyAppBB::startMenu() {
    QmlDocument *qml2 = QmlDocument::create("asset:///MainMenu.qml").parent(this);
    AbstractPane *root2 = qml2->createRootObject<AbstractPane>();

    this->myApp->setScene(root2);
}

Here is the Qml

import bb.cascades 1.0
import bb.data 1.0

Page {
    Container {
        layout: StackLayout {
        }


        TextField {
            id: txtUsername
        }

        ListView {
            id: myListView

            // Associate the list view with the data model that's defined in the
            // attachedObjects list
            dataModel: dataModel
            listItemComponents: [
                ListItemComponent {
                    type: "item"

                    // Use a standard list item to display the data in the data
                    // model
                    StandardListItem {

                        title: ListItemData.identificationType
                        description: ListItemData.identificationTypeId
                    }
                }
            ]
        }
        attachedObjects: [
            GroupDataModel {
                id: dataModel

                // Sort the data in the data model by the "pubDate" field, in
                // descending order, without any automatic grouping
                sortingKeys: [
                    "ID"
                ]
                sortedAscending: false
                grouping: ItemGrouping.None
            },
            DataSource {
                id: dataSource

                source: "http://192.168.150.1/JsonMobileApiService/Service1.svc/GetIDTypes"

                type: DataSourceType.Json
                onDataLoaded: {
                    dataModel.clear();
                    dataModel.insertList(data);
                }
            }
        ]
        onCreationCompleted: {
            txtUsername.setText("boo!");
            // Statement below causes crash
            dataSource.load();
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:18:32+00:00Added an answer on June 17, 2026 at 6:18 am

    There is an onCreationCompleted slot in AbstractPane, you can use that to call load.

    Its in the API spec for the XMLDataAccess as an example. I’m using this to load data from an XML file myself, it works

      import bb.cascades 1.0
      import bb.data 1.0
      Page {
      content: ListView {
        id: listView
        dataModel: dataModel
        ...
      }
      attachedObjects: [
        GroupDataModel {
          id: dataModel
        },
        DataSource {
          id: dataSource
          source: "contacts.xml"
          query: "/contacts/contact"
          onDataLoaded: {
            dataModel.insertList(data);
          }
        }
      ]
      onCreationCompleted: { dataSource.load(); }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some IronPython code that is creating a Mutex using the following constructor:
The following code produces no suitable constructor found error. I am unable to figure
In the following code, the variadic constructor is called twice. How can I get
In the constructor of an object I have the following code: ConfigReader::ConfigReader(){ TiXmlDocument doc(CONFIGURATION_FILE_LOCATION);
In the following code: struct Foo { Foo(int x=0); }; Does the constructor count
I have the following code: Some functions: A::A(int i_a) {cout<<int Ctor\n;} //conversion constructor void
I have the following CoffeeScript code: class Person secret = 0 constructor: (@name, @age,
I get the following error with the code below. expected constructor, destructor, or type
whenever I compile my code, I receive the following errors: error: constructor Player in
I'm dealing with a large code base that uses the following construct throughout class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.