Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
One header file to be used only once in whole program
Thank You last edited by
I have header file named
Suppose with messageBox and one variable
calledVariablefetched from database in constructor
(THIS VARIABLE IS NEVER GONNA CHANGE)
It is used in another header file
And this header file is used in many files
In 10 files.
Here when I do this I get 10 message box with same thing. What I want is to
simple.hONLY once. and get the same variable value
calledVariablewhich we will get in the first execution
@Thank-You Declare the variable es extern in the header file and define it once somewhere in a C++ file.
See https://en.cppreference.com/w/cpp/language/storage_duration for details.
But keep in mind that QObject based classes are not allowed to be instantiated before QApplication instance is created!