How to Instantiate a TouchGFX object dynamically?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-07 5:20 AM
Hi, I use TouchGFX in my HMI project, I want to create an instance of an object (ig. a button) in runtime (dynamically), so I could destroy it later and free it's allocation memory.
I tried create it in a method but it seems to have runtime error:
void Screen1View::create_button()
{
touchgfx::Button button1;
button1.setXY(0, 0);
button1.setBitmaps(touchgfx::Bitmap(BITMAP_BLUE_BUTTONS_ROUND_EDGE_SMALL_ID),
touchgfx::Bitmap(BITMAP_BLUE_BUTTONS_ROUND_EDGE_SMALL_PRESSED_ID));
add(button1);
button1.invalidate();
}
Does anyone have any solution?
Solved! Go to Solution.
- Labels:
-
TouchGFX
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-09 11:22 AM
To my knowledge it can't be done. I asked about this a while back and i believe the answer has something to do with the way TouchGFX is configured.
You will need to place the declaration of that button in your class header file and it should work fine.
Here is @Martin KJELDSEN​ 's explanation on this in the following thread:
https://community.st.com/s/question/0D50X0000AVS2tcSQD/is-it-possible-to-dynamically-add-guiobjects
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-09 11:22 AM
To my knowledge it can't be done. I asked about this a while back and i believe the answer has something to do with the way TouchGFX is configured.
You will need to place the declaration of that button in your class header file and it should work fine.
Here is @Martin KJELDSEN​ 's explanation on this in the following thread:
https://community.st.com/s/question/0D50X0000AVS2tcSQD/is-it-possible-to-dynamically-add-guiobjects
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-09 11:26 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-31 4:40 AM
Thanks. It helped a lot.
