2020-04-01 12:31 AM
2020-04-01 05:34 AM
Just to do something simple:
//Model.hpp
#ifndef MODEL_HPP
#define MODEL_HPP
class ModelListener;
struct MyStruct
{
int a;
int b;
};
class Model
{
public:
Model();
void bind(ModelListener* listener)
{
modelListener = listener;
}
void tick();
protected:
ModelListener* modelListener;
MyStruct s;
};
#endif // MODEL_HPP
//Model.cpp
#include <gui/model/Model.hpp>
#include <gui/model/ModelListener.hpp>
Model::Model() : modelListener(0)
{
s.a = 1;
s.b = 2;
}
void Model::tick()
{
modelListener->setStructValue1(s);
}
2020-04-01 01:02 AM
I have no idea what you're asking :) Can you be more specific? Are you asking a general C++ question here?
/Martin
2020-04-01 01:23 AM
ya its general C++ question, which I am using in TouchGFX. I want to create structure in model.hpp file
typedef struct
{
int16_t Test_hour;
int16_t Test_minute;
} LANG;
I want to use this structure in model.cpp,
How to do that?
if I write LANG.Test_hour in model.cpp file, its is throughing error, it is not recognizing LANG structure.
Now am I bet clear?
2020-04-01 02:25 AM
Can you post your code?
2020-04-01 05:34 AM
Just to do something simple:
//Model.hpp
#ifndef MODEL_HPP
#define MODEL_HPP
class ModelListener;
struct MyStruct
{
int a;
int b;
};
class Model
{
public:
Model();
void bind(ModelListener* listener)
{
modelListener = listener;
}
void tick();
protected:
ModelListener* modelListener;
MyStruct s;
};
#endif // MODEL_HPP
//Model.cpp
#include <gui/model/Model.hpp>
#include <gui/model/ModelListener.hpp>
Model::Model() : modelListener(0)
{
s.a = 1;
s.b = 2;
}
void Model::tick()
{
modelListener->setStructValue1(s);
}
2020-04-08 08:39 AM
Like this are you defining its initial values?
as we define for any variable like this Model::Model() : modelListener(0), hour(0)
?
I want to save structure value in model so that can we used in different screens
2020-04-08 08:40 AM
Like this are you defining its initial values?
as we define for any variable like this Model::Model() : modelListener(0), hour(0)
?
I want to save structure value in model so that can we used in different screens
2020-04-08 09:33 AM
class ModelListener
{
public:
ModelListener() : model(0) { }
virtual ~ModelListener() {}
virtual void setStructValue1( struct s){} // HERE IN LISTENER FUNCTION CAN I PASS STRUCT ?
protected:
Model* model;
};
2020-04-08 10:04 AM
Sure you can!
2020-04-08 10:43 AM
../TouchGFX/gui/include/gui/model/ModelListener.hpp: In member function 'virtual void ModelListener::setStructValue1(s)':
../TouchGFX/gui/include/gui/model/ModelListener.hpp:50:46: error: '<anonymous>' has incomplete type
virtual void setStructValue1( struct s){} //ABC
This error I am getting
I think its not identifying struct s,
How to send struct as parameter? in modelListener and view