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

New Developer
Posts: 20
Registered: ‎03-23-2014
My Device: z10
My Carrier: fido

Cannot use QPointer for QmlDocument

I tried to use QPointer with QmlDocument like this:


QPointer<QmlDocument> qml = QmlDocument::create("asset:///card.qml").parent(this);


I got "conversion from 'bb::cascades::QmlDocument::Builder' to non-scalar type 'QPointer<bb::cascades::QmlDocument>' requested"

The way i see it is that the "create" static method return the inner class Builder and it is not a supported type of QPointer. However, why is it legal to use the pointer of type QmlDocument for its Builder inner class like this:


QmlDocument* qml = QmlDocument::create("asset:///card.qml").parent(this);




Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Cannot use QPointer for QmlDocument

There's operator QmlDocument* defined in Builder:


operator QmlDocument*() {

Assigning it to QmlDocument * variable calls this operator. It seems indirect assignment can't be resolved automatically. Something like this should work:


QPointer<QmlDocument> qml = QmlDocument::create("asset:///card.qml").parent(this).operator QmlDocument*();  // :-))

// OR

QPointer<QmlDocument> qml = (QmlDocument *) QmlDocument::create("asset:///card.qml").parent(this);


Andrey Fidrya, @zmeyc on twitter