Following code is in my c++ class
static const QString ALARM_ERROR_IMAGE ;
i want to initilize
ALARM_ERROR_IMAGE = "error.png";
Is it possible to initilize error.png
to static const QString ALARM_ERROR_IMAGE
Want to keep it inside class
Static variable of a class have to be defined explicitly in the namespace scope only once (irrespective of wheter they are further cv qualified or not).
In the .cpp file (e.g in
<ClassName>.cpp
), in the global namespace (assuming your class is in global namespace), define it as follows (assuming an appropriate constructor exists in QString)NB: I missed 'const' in the definition below
Not possible to keep inside. Only const static integral data members are allowed to initialized inside a class or struct.