Skip to main content
Du1
Associate III
March 1, 2019
Question

Difference between ViewBase() and setupScreen()

  • March 1, 2019
  • 2 replies
  • 1051 views

What's the difference between putting code in:

MyScreenViewBase::MyScreenViewBase(){}

vs

void MyScreenViewBase::setupScreen(){}

This topic has been closed for replies.

2 replies

Martin KJELDSEN
Principal III
March 4, 2019

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
Du1Author
Associate III
March 4, 2019

Thanks again for the detailed explanation!