Can we declare structure in model.hpp and how to use it in model.cpp ? any syntax , example or something
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-01 12:31 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-08 11:11 AM
I thought you were using pseudo code in your last post. You can't pass a struct like that. You need to use the actual type which is a struct. e.g. in c++.
struct mystruct
{
int a;
int b;
};
....
virtual void setStructValue1(mystruct s){}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-09 12:11 AM
Thank you,
In model.cpp
Model::Model() : modelListener(0), hour(0), minute(0),XY(5),AB(0),led_state(false)
{
s.a = 1;
s.b = 2;
}
void Model::tick()
{
modelListener->setStructValue1(s); //que: HOW TO CALL THIS FUNCTION?
}
How to write modelListener->setStructValue1(s); ? This is wrong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-09 12:33 AM
../TouchGFX/gui/src/model/Model.cpp:55:42: error: expected primary-expression before 's'
modelListener->setStructValue1(MyStruct s);
#error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-09 2:10 AM
You can't pass values like that. You're declearing a variable s of type MyStruct as an argument and that's illegal c++ (and C). Can I suggest you do an introductory course on C++? But for what it's worth...
//model.hpp: Declare s to be of type MyStruct to be used in the model
MyStruct s;
//model.cpp
s.a = 1;
s.b = 2;
modelListener->setStructValue1(s);
/Martin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-09 2:45 AM
modelListener->setStructValue1(s);
I have written this, still got error,
Do you have any TouchGFX project in that structure have saved in model and used in view.cpp? if so plz share with me.
Thank you.
I will surely work on your suggestion.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-09 2:53 AM
We have tons - Check any of the demos from the designer and look through the models and modellisteners.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-09 4:35 AM
Ya I have seen examples
I am able to pass integer values in between listener and view but with structure dayatype I haven't came across , which is my concern
I will check if I can get some
Thank you

- « Previous
-
- 1
- 2
- Next »