Skip to main content
Senior
Jun 30, 2025 1:35 PM UTC
Solved

Touchgfx - virtual methods in the "final" Screen class

Hello, I need to use Touchgfx on a small CPU and I'm optimizing my code accordingly. However, in the code that Touchgfx Designer generates, I noticed something that I don't understand:
The Screen classes inherit from the ScreenBase classes.
The Screen classes are actually final, but they have virtual functions, which makes the compiler generate virtual tables for them. The same goes for the Listener classes. Does anyone have any ideas on this?
Best regards

This topic has been closed for replies.
GaetanGodart
GaetanGodartBest answer
ST Employee
Jul 2, 2025 12:00 PM UTC

Hello @Panchev68 ,

 

When you add a screen, there will be a screenViewBase cpp and hpp files created with virtual functions but also a ScreenView cpp and hpp file.
You should not modify the base file as they get regenerated, instead you should overwrite the virtual functions by adding code in the ScreenView files (not the base files).

Is the extra computation required to look at the function table really that impactful? I don't think so, we have been able to design GUI using STM32G0 already (but without FreeRTOS).

 

Regards,

Gaetan GodartSoftware engineer at ST (TouchGFX)

2 replies

GaetanGodart
GaetanGodartBest answer
ST Employee
Jul 2, 2025 12:00 PM UTC

Hello @Panchev68 ,

 

When you add a screen, there will be a screenViewBase cpp and hpp files created with virtual functions but also a ScreenView cpp and hpp file.
You should not modify the base file as they get regenerated, instead you should overwrite the virtual functions by adding code in the ScreenView files (not the base files).

Is the extra computation required to look at the function table really that impactful? I don't think so, we have been able to design GUI using STM32G0 already (but without FreeRTOS).

 

Regards,

Gaetan GodartSoftware engineer at ST (TouchGFX)
Panchev68Author
Senior
Jul 2, 2025 12:10 PM UTC

10 screens ~ -2Kb 

I'm asking out of simple human curiosity. I hope I missed something in C++. This solution plus a few others worked for me.
Congratulations on the wonderful environment you provide.
Best regards