PDA

View Full Version : QT and variable scope



tommy
29th November 2007, 17:28
I have a question that is borderline between Qt and C++.
The program I'm writing consists of many functions distributed between several *.cpp files. Many functions act on the same variables (about 10 total) and there is no reason to hide any variables from any of the functions (all can be public).
Which of the following is the best way to make all variables available to the relevant functions? By best I mean - which is the fastest?

a) Declare all under "public" in the single QWidget class that I use
b) Use variable passing between functions as needed
c) Give all variables global scope by declaring them outside of all functions

wysota
29th November 2007, 21:32
There is no borderline - everything that applies to C++, applies to Qt. Use whatever means you would have used in pure C++ application.