Answer the question
In order to leave comments, you need to log in
How to pass this from a class method to another method of another class?
The bottom line is this, there is an object that came here by reference, it calls the Move method
class StreamFly : public QRunnable
{
private:
FlyObj * flyObjVector; // Вот он в классе
ModuleRls * RLS;
QMutex * mutex;
protected:
void run();
public:
StreamFly(FlyObj&, ModuleRls&, QMutex&);
};
StreamFly::StreamFly(FlyObj &init_ObjList, ModuleRls &init_RLS, QMutex &init_Mutex)
{
flyObjVector = &init_ObjList; // Вот он пришел объект
RLS = &init_RLS;
mutex = &init_Mutex;
}
void StreamFly::run()
{
if (flyObjVector->state.v > 0)
{
mutex->lock();
RLS->Peleng(flyObjVector->typeObj, flyObjVector->objID, flyObjVector->state.x, flyObjVector->state.y);
mutex->unlock();
flyObjVector->Move(); // Вот этот метод
}
}
FilterKalmana filterData; // Объект другого класса в который нужно отправить this
void FlyObj::Move()
{
filterData.approximationFK(this);
}
#include "FlyObj.h"
class FilterKalmana
{
private:
double sigmaPsi = 5.0;
double sigmaEta = 40.0;
/* ------------------- Function ------------------- */
void CorrectX(FlyObj &ObjFilter)
{
//...
}
void CorrectY(FlyObj &ObjFilter)
{
//...
}
public:
void approximationFK(FlyObj &ObjFilter){
CorrectX(ObjFilter);
CorrectY(ObjFilter);
};
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question