SolidModules
nmpropertytest.cpp
Go to the documentation of this file.00001 #include <QtCore/QObject>
00002 #include <QtCore/QString>
00003 #include "nmpropertyhelper.h"
00004
00005 #include <QDebug>
00006
00007 FrobObject::FrobObject() : QObject(0)
00008 {
00009 }
00010 FrobObject::~FrobObject()
00011 {
00012 }
00013
00014 QString FrobObject::frobozz() const
00015 {
00016 return mFrobozz;
00017 }
00018
00019 void FrobObject::setFrobozz(const QString& frob)
00020 {
00021 mFrobozz = frob;
00022 }
00023
00024 int main(int argc, char**argv)
00025 {
00026 FrobObject obj;
00027 NMPropertyHelper hlp(&obj);
00028
00029 QPair<char*,char*> spec;
00030 spec.first = "frobozz";
00031 spec.second = "frobozzChanged";
00032 hlp.registerProperty("frobozz", spec);
00033 hlp.registerProperty("othername", QPair<char*,char*>("myname", 0));
00034
00035 QVariantMap map;
00036 map.insert(QString("frobozz"), QVariant(42.0));
00037 map.insert(QString("othername"), QVariant("pas"));
00038 hlp.deserializeProperties(map);
00039 qDebug("Hello mom");
00040 qDebug() << "map keys: " << map.keys();
00041 qDebug() << "qobj frobozz property (names match): " << obj.property("frobozz");
00042 qDebug() << "qobj myname property (mapped from othername): " << obj.property("myname");
00043 return 0;
00044 }