title: C++ Global Constants in Project
body: <p>I would like to have file in my Qt C++ project that holds all global variables. </p>
  
  <p>Something like: mainvar.h</p>
  
  <p>That I could include in the files where I need access to the globals. </p>
  
  <p>They would hold constants where my settings file is, where I can find the stylesheet and other stuff. </p>
  
  <p>At the moment I have a header file but get the Linker Error: LNK2005 for double definition. </p>
  
  <p>Then, there is #define and extern ... </p>
  
  <p>What's the most modern solution for this and how should I approach this ? 
  The thing is, I dont know yet how many global variables I am going to have.</p>
  
  <p>I come from PHP and things are slightley different over there. Looking forward to your help.</p>
  
  <p><strong>Edit1 :</strong></p>
  
  <p>OK, after the comments, here is some code:
  I have ejected the old code, so this is holding already the code from the first comment to create a Class:</p>
  
  <pre><code>QFile settingsFile(GlobalSettings::getSettingsFileStr());
  if (!settingsFile.exists())
  {
      //create the settings file
      settingsFile.open(QIODevice::ReadWrite);
      settingsFile.close();
      loadSettings("://src/settings_default.ini");
  }
  else
  {
      loadSettings("");
  }
  </code></pre>
  
  <p>In this Setting file I have saved weather a TrayIcon is shown or not when the user closes the application. </p>
  
  <p>Later I want to use this setting in the MainWindow Class. Such as:</p>
  
  <pre><code>QSettings settings(GlobalSettings::getSettingsFileStr(), QSettings::IniFormat);
  
  if ( settings.value("general/trayIcon").toBool() )
  {
      event-&gt;ignore();
      showTrayIcon();
      this-&gt;hide();
  }
  </code></pre>
  
  <p>I hope the edit adds clarity.</p>
  
  <p>All the best, 
  Richard</p>