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
Developer
Developer
mdd
Posts: 222
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,

Please use plain text.
BlackBerry Development Advisor
PBernhardt
Posts: 740
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
Please use plain text.