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
Highlighted
Regular Contributor
Posts: 51
Registered: ‎04-24-2013
My Device: Z10
My Carrier: Telkomsel

Load ImageView From http with default image

Hi i am trying to load view from http, and it works. But sometimes there is not image to display, so i want to display image from my local  (asset) folder when the url is not found.

 


Here my code, where i copy paste from this forum:

 

const QUrl& WebImageView::url() const {
	return mUrl;
}


void WebImageView::setUrl(const QUrl& url) {
	mUrl = url;

	QNetworkReply * reply = mNetManager->get(QNetworkRequest(url));
		 connect(reply,SIGNAL(finished()), this, SLOT(imageLoaded()));
		 	emit urlChanged();
}

void WebImageView::imageLoaded() {

	QNetworkReply * reply = qobject_cast<QNetworkReply*>(sender());
	setImage(Image(reply->readAll()));

}

 

Where i should put any code (and what).

Thanks.