Using QXmlStreamReader to read configuration file of key-value pairs
Case for not using a class

It's not clear to me whether you need a class for what you are doing. Unless you need to be able to construct an instance of ConfigurationReader and pass it around, I would say get rid of the class. You can have a function with the simple interface

QHash&lt;QString, QString&gt; getConfigurationMap(QFile&amp; input);


I would further suggest putting the function in a namespace that is specific to your app.

namespace MyApp
{
   QHash&lt;QString, QString&gt; getConfigurationMap(QFile&amp; input);
}


Use smaller functions

Instead of one large function, divide the code into multiple functions. Think of what you are doing rather than how you are doing it. The whats usually translate to smaller functions and hows translate to loops, conditionals, branches, etc.

Given that, getConfigurationMap can be implemented as:

namespace MyApp
{
   // Implementation detail.
   void getConfigurationMap(QXmlStreamReader&amp; reader,
                            QHash&lt;QString, QString&gt;&amp; map);

   // User facing interface.
   QHash&lt;QString, QString&gt; getConfigurationMap(QFile&amp; input)
   {
      QXmlStreamReader reader(input);
      QHash&lt;QString, QString&gt; map;
      getConfigurationMap(reader, map);
      return map;
   }
}


The second overload (the one that's listed first) can be implemented as:

namespace MyApp
{
   void skipUntilConfiguration(QXmlStreamReader&amp; reader);

   void readParamters(QXmlStreamReader&amp; reader,
                      QHash&lt;QString, QString&gt;&amp; map);

   // Implementation detail.
   void getConfigurationMap(QXmlStreamReader&amp; reader,
                            QHash&lt;QString, QString&gt;&amp; map);
   {
      skipUntilConfiguration(reader);
      readParamters(reader, map):
   }

   // User facing interface.
   QHash&lt;QString, QString&gt; getConfigurationMap(QFile&amp; input)
   {
      QXmlStreamReader reader(input);
      QHash&lt;QString, QString&gt; map;
      getConfigurationMap(reader, map);
      return map;
   }
}


The code can be wrapped up by implementing the final two helper functions.

namespace MyApp
{
   void skipUntilConfiguration(QXmlStreamReader&amp; reader)
   {
      whiile ( !reader.atEnd() )
      {
         if ( reader.tokenType() == QXmlStreamReader::StartElement &amp;&amp;
              reader.name() == "configuration" )
         {
            return;
         }
      }
   }

   void readParamters(QXmlStreamReader&amp; reader,
                      QHash&lt;QString, QString&gt;&amp; map)
   {
      while ( reader.readNextStartElement() ) {
          if ( reader.name() == "parameter" ) {
              QString id = reader.attributes().value("id").toString();
              map.insert(id, reader.readElementText());
          }
          else {
              reader.skipCurrentElement();
          }
      }
   }

   void getConfigurationMap(QXmlStreamReader&amp; reader,
                            QHash&lt;QString, QString&gt;&amp; map)
   {
      skipUntilConfiguration(reader);
      readParamters(reader, map):
   }

   QHash&lt;QString, QString&gt; getConfigurationMap(QFile&amp; input)
   {
      QXmlStreamReader reader(input);
      QHash&lt;QString, QString&gt; map;
      getConfigurationMap(reader, map);
      return map;
   }
}


The above code assumes that there is only one "configuration" element in your XML file. If that assumption is not correct, the functions need to be tweaked a bit.