Hello, i got a question.

Consider the following code

parser.h

Qt Code:
  1. class parser : public QObject
  2.  
  3. {
  4. Q_OBJECT
  5. public:
  6. explicit parser(QObject *parent = 0);
  7.  
  8. void process_line(QString line, QMap<QString,double> my_map);
  9. int read_line(QMap<QString,double> my_map);
  10. void print_map(QMap<QString,double> my_map);
  11.  
  12. };
To copy to clipboard, switch view to plain text mode 

parser.cpp

Qt Code:
  1. void parser::process_line(QString line, QMap<QString, double> my_map)
  2. {
  3. QStringList temporary_list;
  4.  
  5. for(int i = 0; i< currency_list.size();i++)
  6. {
  7. if(line.contains(currency_list.at(i),Qt::CaseInsensitive))
  8. {
  9. qDebug()<<"found"<< currency_list.at(i);
  10. temporary_list=line.split(" ",QString::SkipEmptyParts);
  11. qDebug()<< temporary_list[6];
  12. temporary_list.replaceInStrings(",",".");
  13. my_map.insert(currency_list.at(i),temporary_list[6].toDouble());
  14. }
  15. }
  16.  
  17. }
  18.  
  19. int parser::read_line(QMap<QString, double> my_map)
  20. {
  21.  
  22. QFile file("C:/Qt/test/downloaded.txt");
  23.  
  24. if(!file.exists())
  25. {
  26. QMessageBox msgBox;
  27. msgBox.setText("There is no such file");
  28. msgBox.exec();
  29. return 1;
  30. }
  31.  
  32. if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
  33. {
  34. QMessageBox msgBox;
  35. msgBox.setText("Error while opening file");
  36. msgBox.exec();
  37. return 1;
  38. }
  39.  
  40. QTextStream in_stream(&file);
  41. QString line=in_stream.readLine();
  42.  
  43.  
  44. while (!line.isNull())
  45. {
  46. process_line(line, my_map);
  47. line = in_stream.readLine();
  48. }
  49.  
  50.  
  51. return 0;
  52. }
  53.  
  54. void parser::print_map(QMap<QString, double> my_map)
  55. {
  56. QMapIterator<QString, int> i(map);
  57. while (i.hasNext()) {
  58. i.next();
  59. qDebug()<< i.key() << ": " << i.value() << endl;
  60. }
To copy to clipboard, switch view to plain text mode 

i tried this to test for data.

Qt Code:
  1. void parser::print_map(QMap<QString, double> my_map)
  2. {
  3. QMapIterator<QString, int> i(map);
  4. if(!i.hasNext()) {
  5. qDebug()<< "nothing here" << endl;
  6. }
To copy to clipboard, switch view to plain text mode 

and it shows that nothing is there

and in my main

main.cpp

Qt Code:
  1. int main(int argc, char *argv[])
  2. {
  3. QApplication a(argc, argv);
  4.  
  5. QMap<QString,double> currency_map;
  6.  
  7. MainWindow w;
  8. w.show();
  9.  
  10. parser p;
  11. p.read_line(currency_map);
  12.  
  13. p.print_map(currency_map);
  14.  
  15. return a.exec();
  16. }
To copy to clipboard, switch view to plain text mode 


What am i doing wrong while trying to print (and maybe even saving) keys/values in my map?
my read_line() works ok, qdebugger is showing everything and im also under the impression that my process_line works ok as well.

I need to use the map in other classes as well, so im thinking it would be most painless to make it in my main and send it around.
But im obviously missing something here, would appreciate it if you could help me out.

Thx