cancel
Showing results for 
Search instead for 
Did you mean: 

Variables from Screen1ViewBase are not accessible from Screen1View. I get "VariableName" was not declared in this scope.

CStir.1
Associate III

I have a variable declare in protected area of the Screen1ViewBase Class: "touchgfx::IconButtonStyle< touchgfx::ClickButtonTrigger > BlinkyAlertIcon;"

and I want to use this variable in Screen1View which is publicly derived from Screen1ViewBase. I receive "was not declared in this scope" error. I'm using STM32CubeIDE Version 1.5.1 and ToughGFX Version 4.16. Looks like a noob problem I'm I missing any include paths? Or does anyone solved this problem? The files are generated by TouchGFX Designer

1 ACCEPTED SOLUTION

Accepted Solutions

Thank You all, the problem was very silly because I didn't program in C++ for 10 years or so, and I made a stupid mistake my function definition in cpp file was missing the Class Name and :: before the function name, and of course that the variable was out of scope because my function was declared outside the class.

I'm sorry for wasting your time.

Problem Solved!

Regards,

Claudiu

View solution in original post

6 REPLIES 6
Javier1
Principal

The reason why this happens to me sometimes is because the variable i am trying to screen is declared as volatile inside some function, maybe try to declare your variable as global as you can and debug from there? .......or pause your debugger right when the class is created to check if it shows.

we dont need to firmware by ourselves, lets talk
MM..1
Chief II

ViewBase is generated and overwrited on every touch regenerate code, how you enter your variable in base ???

Hello, yes I know that, I didn't write my self variables in ViewBase they were generated by the TouchGFX Designer.

This one, for example: touchgfx::IconButtonStyle< touchgfx::ClickButtonTrigger > BlinkyAlertIcon; is an IconButton. The problem is that I can't used it in ScreenView. Is not reconized by the IDE and if I compile I get "BlinkyAlertIcon" was not declared in this scope. And this is happening with all the Buttons, Labels etc.

I know that in the ViewBase Class those variables are in the protected area but ScreenView is inherited from ViewBase. So I don't understand very well the error.

Claudiu

Hello CStir.1,

It 's true it's very strange and I actually cannot reproduce it. Everything generated by Designer is supposed to be compiled correctly and accessible by the child class.

Make sure your ViewBase is correctly included in your View.

One suggestion would be to create a new UI from zero and simply insert your Flex button and see if it happens again.

Lastly, maybe try to reinstall TouchGFX.

/Alexandre

MM..1
Chief II

Maybe you need simply refresh project after generate new objects in touchgfx. When you plan use show methods build before write new code...

Thank You all, the problem was very silly because I didn't program in C++ for 10 years or so, and I made a stupid mistake my function definition in cpp file was missing the Class Name and :: before the function name, and of course that the variable was out of scope because my function was declared outside the class.

I'm sorry for wasting your time.

Problem Solved!

Regards,

Claudiu