title: Initializing qt resources embedded in static library
body: <p>I have next situation: I need to create widget in standalone static library, which then will be linked with final application (visual c++ 9.0, qt 4.5).
  This static widget library contains some resources (icons), and consist of a several .cpp files (each contains standalone widget). As far as I know, i must initialize qt resource system, if i use them (resources) in static library, with call to "Q_INIT_RESOURCE( resource_file_name )". I solved this with next code (in every .cpp file in static library):</p>
  
  <pre>
  <code>
  #include &lt;QAbstractButton&gt;
  
  namespace {
  struct StaticLibInitializer
  {
      StaticLibInitializer()
      {
          Q_INIT_RESOURCE(qtwidgets_custom_resources);
      }
  };
  StaticLibInitializer staticLibInitializer;
  } 
  
  // ... widget code ....
  </code>
  </pre>
  
  <p>Instead of my first approach, I have created separate init.cpp file in static library project with initialization code (to avoid including initialization code in every .cpp file), but this didn't work.</p>
  
  <p>Why this didn't work ?</p>
  
  <p>Is this approach with StaticLibInitializer is safe and portable among various compilers and platforms ?</p>