Variable that is updated whenever a button is presssed in Qt GUI application
-
I have some background in C but am otherwise an electronic engineer that designs digital circuits.
I am trying to understand how Qt programs are structured.
Lets take an example. A Qt GUI program has a button. Everytime that button is pressed, a counter goes up. Now this counter could be declared inside the program's main or it could be declared inside the MainWindow class private area. Where should such a variable be put?
-
I have some background in C but am otherwise an electronic engineer that designs digital circuits.
I am trying to understand how Qt programs are structured.
Lets take an example. A Qt GUI program has a button. Everytime that button is pressed, a counter goes up. Now this counter could be declared inside the program's main or it could be declared inside the MainWindow class private area. Where should such a variable be put?
Hi and welcome :)
@okhajut said in Variable that is updated whenever a button is presssed in Qt GUI application:
could be declared inside the program's main
You could, but makes no sense in this case.
declared inside the MainWindow class private area
That's what you should do.
Depends on what you want to do further and where/for what the variable is used later.
You might want to write some getters or add signals to it.Btw: If you only have some plain C knowledge, you should read about OOP and C++ basics first, before/while you start with Qt.