2022-11-02 11:54 AM
Hello, is it possible to add for example a line on the canvas at run time? I'm managing to do a log x scale providing the decades separators with a Line object, but my plot could have more than one decade, so i think is a terrible idea to add many lines as i want, and then making each one visible as it is required. So a tried to add lines at run time but i couldn't manange to do it. I didnt expected to work because it's probable that im jumping many layers of TouchGFX.
This part of code was written from me in Screen1View.cpp - void Screen1View::DataDisplay():
touchgfx::Line line4;
touchgfx::PainterRGB565 line4Painter;
line4.setPosition(204, 0, 23, 240);
line4Painter.setColor(touchgfx::Color::getColorFromRGB(255, 255, 255));
line4.setPainter(line4Painter);
line4.setStart(0, 240);
line4.setEnd(0, 0);
line4.setLineWidth(4);
line4.setLineEndingStyle(touchgfx::Line::ROUND_CAP_ENDING);
add(line4);
Thank you very much.
Solved! Go to Solution.
2022-11-03 05:18 AM
Hello @JPine.1 ,
We don't recommend creating and adding widgets on runtime with TouchGFX, because it could result in a lot of memory issues. Something that you could do is create the widget you want to display on the canvas view in the Designer, and then uncheck the "Make visible" checkbox.
Then, in your code, you could simply call the function setVisible(true) to display it on the UI, when you want.
I know that you might sometimes prefer to create dynamically some object in your code, but that's the best option for the moment.
Hope I helped you,
/Yoann
2022-11-03 05:18 AM
Hello @JPine.1 ,
We don't recommend creating and adding widgets on runtime with TouchGFX, because it could result in a lot of memory issues. Something that you could do is create the widget you want to display on the canvas view in the Designer, and then uncheck the "Make visible" checkbox.
Then, in your code, you could simply call the function setVisible(true) to display it on the UI, when you want.
I know that you might sometimes prefer to create dynamically some object in your code, but that's the best option for the moment.
Hope I helped you,
/Yoann
2022-11-06 01:47 PM
Ok, i have done that. Thank you very much!