8
Is there a way to initialize a variable in a function and save its value for next call of function?
I'm making application in qt and i have one function connected with a signal. I want an variable in that function to change after the other one reaches its goal. Here is the body of that function:
void objekt::advance(int phase)
{
if(!phase) return;
QPointF location = this->pos();
if (int(location.x())==200 || int(location.x())==-200)
{
smijer=-smijer;
}
setPos(mapToParent(smijer,0));
}
I defined the smijer variable as static int. But i dont'know how to initialize it only once, when program starts, and how to keep its new value after each call of the function.