jobrandt
7th May 2007, 10:37
I have list of properties. Each property has a name and a QVariant value. I can access each property over the name(like QSettings).
I want to connect some property to a concrete global variable. If the value of property is changed the global variable should also be changed.
Here is some code to to show what i mean.
// global variable
double xy; // could be any other type (e.g int,QPoint,QString etc.)
class Prop
{
private:
QString mName;
QVariant mValue;
QVariant /*or void?? */ *mPointer; // should point to xy
public:
void SetPointer(/*Pointer to xy*/)
{
mPointer = /*Pointer to xy*/;
}
void SetGlobalVariabel()
{
// should set xy indirect with mPointer
*/*Pointer to xy*/ = mValue.value();
}
};
Is this possible? If yes, how can i do this.
There are other ways to change the global variable. But also this way should work.
I want to connect some property to a concrete global variable. If the value of property is changed the global variable should also be changed.
Here is some code to to show what i mean.
// global variable
double xy; // could be any other type (e.g int,QPoint,QString etc.)
class Prop
{
private:
QString mName;
QVariant mValue;
QVariant /*or void?? */ *mPointer; // should point to xy
public:
void SetPointer(/*Pointer to xy*/)
{
mPointer = /*Pointer to xy*/;
}
void SetGlobalVariabel()
{
// should set xy indirect with mPointer
*/*Pointer to xy*/ = mValue.value();
}
};
Is this possible? If yes, how can i do this.
There are other ways to change the global variable. But also this way should work.