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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Highlighted
Developer
Developer
Posts: 227
Registered: ‎01-17-2012
My Device: PB
My Carrier: ATT

Help for QMetaType

I'm trying to persist the following custom class using JSON:

 

class StoredProfile: public QObject
{
	Q_OBJECT

private:
	QString m_url;	// or user's account name/email
	QString m_usr;	// or consumer key
public:
	StoredProfile(const QString& url = 0, const QString& usr = 0);
	 StoredProfile(const StoredProfile &p);

 	virtual ~StoredProfile();

	const QString& url() const {
		return m_url;
	}

	void setUrl(const QString& url) {
		qDebug() << "setUrl:" << url;
		m_url = url;
	}


	const QString& usr() const {
		return m_usr;
	}

	void setUsr(const QString& usr) {
		qDebug() << "setUsr:" << usr;
		m_usr = usr;
	}
};

Q_DECLARE_METATYPE( StoredProfile )

 When this object is saved using BB JsonAccessData, "null" is written (to the buffer/file).

 

Does the custom class need to provide other methods to allow JsonAccessData to convert to a QVariantMap?

 

Regards,

Retired
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: Help for QMetaType

You can only pass in an actual QVariantMap or QVariantList to the save fucntion on JSON Data Access. You could store the data inside StoredProfile as a QVariantMap and then pass that map into JsonDataAccess.

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker