Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Developer
Posts: 133
Registered: ‎10-01-2012
My Device: Playbook
My Carrier: CMCC

HTTP communication example isn't working

Hi,

I am trying out HTTP example to load XML file as list from the following tutorial- HTTP communication

 

However, I failed to run it. There is an update for HttpContactList.cpp for gold SDK. We need to use createRootObject instead of createRootNode in line 24 (reference). Then it compiles fine. But it doesn't run. What is wrong? 

Contributor
Posts: 15
Registered: ‎03-02-2013
My Device: Blackberry Z10
My Carrier: telcel

Re: HTTP communication example isn't working

[ Edited ]

I have the same problem with that example, i use the following code in the .hpp file: 

 

#ifndef App_HPP_
#define App_HPP_

#include <QObject>
#include <QFile>
#include <bb/cascades/ActivityIndicator>
#include <bb/cascades/ListView>

namespace bb {
namespace cascades {
class Application;
class Container;
class ListView;
class NavigationPane;
class Page;
class ActivityIndicator;
}
}

/*!
 * @brief Application pane object
 *
 *Use this object to create and init app UI, to create context objects, to register the new meta types etc.
 */
class App: public QObject {

Q_OBJECT

public:
	App(bb::cascades::Application *app);Q_INVOKABLE
	void initiateRequest();

private slots:
	/*!
	 * Handles the network reply.
	 */
	void requestFinished(QNetworkReply* reply);

private:
	bb::cascades::ActivityIndicator *mActivityIndicator;
	bb::cascades::ListView *mListView;
	QNetworkAccessManager *mNetworkAccessManager;
	QFile *mFile;

	virtual ~App() {
	}

};

#endif /* App_HPP_ */

 

instead of:

ActivityIndicator *mActivityIndicator;
ListView *mListView;

use:

bb::cascades::ActivityIndicator *mActivityIndicator;
bb::cascades::ListView *mListView;

 

Also use this url to get the xml sample file:

 

https://developer.blackberry.com/cascades/files/documentation/images/model.xml

 

i hope this can help you

Developer
Posts: 125
Registered: ‎10-02-2011
My Device: Playbook
My Carrier: none

Re: HTTP communication example isn't working

I'm having the same problem the app compiles, but doesn't open.  I think it has something to do with these errors:

 

bb::cascades::QmlDocument: error when loading QML from:   QUrl( "file:main.qml" ) 
--- errors: (file:///accounts/1000/appdata/com.example.HttpContactList.testDev_ContactListfafe4125/main.qml: File
not found)
bb::cascades::QmlDocument:createRootObject document is not loaded or has errors, can't create root 

 Has anyone been able to get this example working?

Developer
Posts: 196
Registered: ‎03-04-2013
My Device: BB Z10
My Carrier: Rogers

Re: HTTP communication example isn't working

The way that you have specified the main.qml file is probably incorrect... Try it this way:

 

QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(app);

 

Developer
Posts: 125
Registered: ‎10-02-2011
My Device: Playbook
My Carrier: none

Re: HTTP communication example isn't working

Yep that fixed it. Thanks.