[SOLVED]Function pointer
-
Hi gurus!
How i can do something like this:This is the class that stores data item and it has a pointer to function for some manipulation with data
@class VariableItem
{
....
void (*SomeAction)();
}
@This is the main class that stores all data
@class MainClass
{
QList<VariableItem> variableList;
void action1();
void action2();
void action3();
}
@
and as you guess VariableItem::SomeAction must get adress of one action from MainClass
Using global functions solve this but i want use member methods. Maybe Qt already has solution for this cases? -
Seems like a task for signal-slot mechanism.
-
[quote author="qxoz" date="1350648921"]Yeah
But in some cases i need feedback.
@class MainClass
{
QList<VariableItem> variableList;
bool action1(QByteArray *, int *);
bool action2(QByteArray *, int *);
bool action3(QByteArray *, int *);
}@edit
Maybe something like delegates?[/quote]"delegate" means in Qt world a special kind of controller.
Signal/slot can help you beacuse the slot is a "simple" method what can return any arbitrary data.
Maybe the signapmapper is the right choice here.