Qt-interest Archive, June 2007
application wide variables
Message 1 in thread
Hello,
I'm new to Qt. I want to store variables in mainwindow that can be reached / accessed from all other dialog window (outside the mainwindow). Here is my plan :
class MainWindow : public QMainWIndow
{
Q_OBJECT
public:
int some_public_function();
some_public_procedure();
some_public_variables;
protected:
...
...
private slots:
...
...
private:
...
...
}
Is this the correct / recomended way to do such thing in Qt ?. What is the best practice to do this thing in Qt ?.
Thanks in advance.
regard,
si sol
____________________________________________________________________________________
Park yourself in front of a world of choices in alternative vehicles. Visit the Yahoo! Auto Green Center.
http://autos.yahoo.com/green_center/
--
[ signature omitted ]
Message 2 in thread
Hi,
SI SOL wrote:
> Hello,
>
> I'm new to Qt. I want to store variables in mainwindow that can be reached / accessed from all other dialog window (outside the mainwindow). Here is my plan :
> [...]
> Is this the correct / recomended way to do such thing in Qt ?. What is the best practice to do this thing in Qt ?.
>
>
You can do It this way, but a cleaner solution is to use get/set Methods
for your variables. You may also have to check for threading
issues/concurrent access by different threads, etc. (Check out QMutex
for more).
You also should read more about the basic principles of OO-Programming
(object orientated programming) and information hiding, since your
question is one of the basic questions in OO-Programming and explained
in every OO-Programming book for beginners.
Greets,
Jochen
--
[ signature omitted ]