Cannot call a function
-
wrote on 3 Sept 2020, 08:56 last edited by
Hello, I cannot call a function from another function. I do not know what is wrong. I have a function that returns double :
double calculateMathVectors();
That is how it is defined in header under private: section. Then when I try to call it from another function as:
void protocolForm::receiveMathSignals(QString selected1, QString selected2, QString operation, QString signalName) { protocolForm::calculateMathVectors(); }
At the beginning of the called function there is qDebug().
double protocolForm::calculateMathVectors() { qDebug()<< "entered"; . . . }
But it never enters to that qDebug(). How might be wrong? Probably I am missing a very simple thing.
-
Hello, I cannot call a function from another function. I do not know what is wrong. I have a function that returns double :
double calculateMathVectors();
That is how it is defined in header under private: section. Then when I try to call it from another function as:
void protocolForm::receiveMathSignals(QString selected1, QString selected2, QString operation, QString signalName) { protocolForm::calculateMathVectors(); }
At the beginning of the called function there is qDebug().
double protocolForm::calculateMathVectors() { qDebug()<< "entered"; . . . }
But it never enters to that qDebug(). How might be wrong? Probably I am missing a very simple thing.
-
Hello, I cannot call a function from another function. I do not know what is wrong. I have a function that returns double :
double calculateMathVectors();
That is how it is defined in header under private: section. Then when I try to call it from another function as:
void protocolForm::receiveMathSignals(QString selected1, QString selected2, QString operation, QString signalName) { protocolForm::calculateMathVectors(); }
At the beginning of the called function there is qDebug().
double protocolForm::calculateMathVectors() { qDebug()<< "entered"; . . . }
But it never enters to that qDebug(). How might be wrong? Probably I am missing a very simple thing.
wrote on 3 Sept 2020, 09:19 last edited by KroMignon 9 Mar 2020, 09:20@GunkutA said in Cannot call a function:
Probably I am missing a very simple thing.
Perhaps you have to learn a little bit more C++ language basics?
If you want to call a function from your class, simply call it!double protocolForm::calculateMathVectors() { qDebug()<< "entered"; ... } void protocolForm::receiveMathSignals(QString selected1, QString selected2, QString operation, QString signalName) { calculateMathVectors(); }
Just another hint, it is recommended to use UpperCamelCase for class names and lowerCamelCase for function names.
So your class name should be ProtocolForm. -
@GunkutA
It looks like you should just call it viacalculateMathVectors();
. However, put aqDebug()
intoprotocolForm::receiveMathSignal()
first line, prove that is being called in the first place? -
@GunkutA said in Cannot call a function:
Probably I am missing a very simple thing.
Perhaps you have to learn a little bit more C++ language basics?
If you want to call a function from your class, simply call it!double protocolForm::calculateMathVectors() { qDebug()<< "entered"; ... } void protocolForm::receiveMathSignals(QString selected1, QString selected2, QString operation, QString signalName) { calculateMathVectors(); }
Just another hint, it is recommended to use UpperCamelCase for class names and lowerCamelCase for function names.
So your class name should be ProtocolForm.wrote on 3 Sept 2020, 09:21 last edited by@KroMignon When I simply call it, still not printing the qDebug().
-
@KroMignon When I simply call it, still not printing the qDebug().
wrote on 3 Sept 2020, 09:23 last edited by@GunkutA said in Cannot call a function:
When I simply call it, still not printing the qDebug().
Are you sure you are running the right code (e.g. do you have build it successfully)?
Do you have tried to set breakpoint and start in debug mode? -
@JonB There is a qDebug() in the first line of protocolForm::receiveMathSignal(). When I simply called calculateMathVectors(); still not entering the function sadly.
wrote on 3 Sept 2020, 09:30 last edited by JonB 9 Mar 2020, 09:31@GunkutA said in Cannot call a function:
@JonB There is a qDebug() in the first line of protocolForm::receiveMathSignal().
No there isn't, you have shown the code of
protocolForm::receiveMathSignals()
method and there is no such statement. -
@GunkutA said in Cannot call a function:
@JonB There is a qDebug() in the first line of protocolForm::receiveMathSignal().
No there isn't, you have shown the code of
protocolForm::receiveMathSignals()
method and there is no such statement. -
@GunkutA said in Cannot call a function:
When I simply call it, still not printing the qDebug().
Are you sure you are running the right code (e.g. do you have build it successfully)?
Do you have tried to set breakpoint and start in debug mode?wrote on 3 Sept 2020, 09:40 last edited by@KroMignon I forgot to connect signal and slots, my bad :( and thanks
5/9