cancel
Showing results for 
Search instead for 
Did you mean: 

Difference between ViewBase() and setupScreen()

Du1
Senior

What's the difference between putting code in:

MyScreenViewBase::MyScreenViewBase(){}

vs

void MyScreenViewBase::setupScreen(){}

2 REPLIES 2
Martin KJELDSEN
Chief III

Hi @Du​,

In a way there isn't, but conceptually, TouchGFX will tear down the "current" screen before calling "setupScreen" on the new screen being switched to. If you put all your initialization code in the constructor you would have constructed a new screen before the old one has been torn down which may or may not cause problems for you.

It's best practice to put screen specific initialization code in setupScreen(). You could still put other initialization code in the constructor.

Best regards,

Martin

Du1
Senior

Thanks again for the detailed explanation!