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
Developer
Posts: 435
Registered: ‎09-20-2011
My Device: Z10 LE, Playbook, DevAlpha C, 9900, 9380
My Carrier: Vodafone

Problem with GridList

[ Edited ]

Hi all,

 

Can anyone point me what i'm doing wrong. I'm not getting the desired GridList.

 

My QML

import bb.cascades 1.0
import bb.data 1.0

Page {
 content: Container {
 layout: DockLayout {
}
ListView {
id: myListView
objectName: "myListView"
layout: GridListLayout {
columnCount: 3
}

listItemComponents: [
ListItemComponent {
type: "contact"
Container {
verticalAlignment: VerticalAlignment.Fill
horizontalAlignment: HorizontalAlignment.Fill
background: Color.Magenta
ImageView {
imageSource: ListItemData.image_url
scalingMethod: ScalingMethod.AspectFit
layoutProperties: StackLayoutProperties {
spaceQuota: 1.0
}
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Center
}
Label {
text: ListItemData.created_at
textStyle.base: SystemDefaults.TextStyles.SmallText
horizontalAlignment: HorizontalAlignment.Center
}

}
}
]
}
}
}

 

 

My CPP Code

 

// Default empty project template
#include "Foto.hpp"

#include <bb/cascades/Application>
#include <bb/cascades/QmlDocument>
#include <bb/cascades/Page>
#include <bb/cascades/Container>
#include <bb/cascades/AbstractPane>
#include <qt4/QtNetwork/qnetworkrequest.h>
#include <qt4/QtNetwork/qnetworkreply.h>
#include <bb/data/JsonDataAccess>
#include <bb/cascades/GridListLayout>

using namespace bb::cascades;

Foto::Foto(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
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
// create root object for the UI
qml->setContextProperty("myListView",this);

Page *root = qml->createRootObject<Page>();
myListView = root->findChild<ListView*>("myListView");
myGroupModel = new GroupDataModel(QStringList() << "created"<<"image");
myGroupModel->setGrouping(ItemGrouping::None);

myNetworkAccessManager = new QNetworkAccessManager();

bool result = connect(myNetworkAccessManager,
SIGNAL(finished(QNetworkReply*)),
this, SLOT(requestFinished(QNetworkReply*)));

Q_ASSERT(result);
Q_UNUSED(result);

myNetworkAccessManager->get(QNetworkRequest(QUrl("https:URL")));
myListView->setDataModel(myGroupModel);
app->setScene(root);
}

void Foto::requestFinished( QNetworkReply * reply){

QVariantMap dataName;

if (reply) {
if (reply->error() == QNetworkReply::NoError) {
const int available = reply->bytesAvailable();

if (available > 0) {
const QByteArray buffer(reply->readAll());

bb::data&colon;:JsonDataAccess ja;
const QVariant jsonva = ja.loadFromBuffer(buffer);
const QVariantMap jsonreply = jsonva.toMap();

QVariantList data = jsonreply["photos"].toList();
foreach(QVariant v, data){
dataName["created"]=v.toMap().value("created").toString();myGroupModel->insert(dataName);
dataName["image"]=v.toMap().value("image").toString();myGroupModel->insert(dataName);

}
}
} else {
}
reply->deleteLater();
}
}

 

 

What required

 

Required

 

 

But iam getting

 

getting

 

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Problem with GridList

It takes a while for pictures to get approved and show up, best to put a textual description of your problem as well.

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 202
Registered: ‎02-10-2011
My Device: Playbook 16GB and Z10
My Carrier: Verizon

Re: Problem with GridList

I have had issues loading images from remote URL's unfortunately I think you will need to download the image to a temp dir and use a local url for your images.

_________________________________________________
Apps
Go Music
Flashlight Fast Free/Pro
Fitbit for BlackBerry PlayBook
Contributor
Posts: 33
Registered: ‎01-13-2013
My Device: BlackBerry Z10, Q10
My Carrier: Claro (Brazil)

Re: Problem with GridList

Already answered here.

Developer
Posts: 435
Registered: ‎09-20-2011
My Device: Z10 LE, Playbook, DevAlpha C, 9900, 9380
My Carrier: Vodafone

Re: Problem with GridList