Hello,

I have a problem qfile.Here is my code:

Qt Code:
  1. void Graph::readWrite(const QString &fileLoca){
  2. QFile inFile(fileLoca);
  3.  
  4. if(inFile.open(QIODevice::ReadWrite | QIODevice::Text)){
  5.  
  6. QTextStream in(&inFile);
  7. source = in.readLine();
  8. while(!in.atEnd()){
  9. QString v,m;
  10. QString line = in.readLine();
  11. double price;
  12. v = str_split(line,'-');
  13. m = str_split(line,':');
  14. price = line.toDouble();
  15. this->addEdge(v,m,price);
  16. }
  17.  
  18. in << endl << "cost : " << kruskal();
  19. inFile.close();
  20.  
  21. }
  22.  
  23. }
To copy to clipboard, switch view to plain text mode 

line 18 "endl" not working and my file failing.for example here is my file.
D
A-B:2
A-D:5
A-F:6
B-C:8
B-D:6
C-D:3
C-E:5
D-E:6
D-F:7
E-F:2
and i want this
D
A-B:2
A-D:5
A-F:6
B-C:8
B-D:6
C-D:3
C-E:5
D-E:6
D-F:7
E-F:2
cost : 17
but i see this
DA-B:2A-D:5A-F:6B-C:8B-D:6C-D:3C-E:5D-E:6D-F:7E-F:2cost : 17
What is my problem ?

and my second problem i'm working draw text on my graphic screen and i use qpainter class and drawText().
I have two point and string so i used drawtext(QPointF(x,y),string) and this func. begin write (x,y) point but i want (x,y) point is my string center point.How can i do this.

Thanks.