seniorc
27th March 2014, 19:41
Hello,
I have a problem qfile.Here is my code:
void Graph::readWrite(const QString &fileLoca){
QFile inFile(fileLoca);
if(inFile.open(QIODevice::ReadWrite | QIODevice::Text)){
QTextStream in(&inFile);
source = in.readLine();
while(!in.atEnd()){
QString v,m;
QString line = in.readLine();
double price;
v = str_split(line,'-');
m = str_split(line,':');
price = line.toDouble();
this->addEdge(v,m,price);
}
in << endl << "cost : " << kruskal();
inFile.close();
}
}
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.
I have a problem qfile.Here is my code:
void Graph::readWrite(const QString &fileLoca){
QFile inFile(fileLoca);
if(inFile.open(QIODevice::ReadWrite | QIODevice::Text)){
QTextStream in(&inFile);
source = in.readLine();
while(!in.atEnd()){
QString v,m;
QString line = in.readLine();
double price;
v = str_split(line,'-');
m = str_split(line,':');
price = line.toDouble();
this->addEdge(v,m,price);
}
in << endl << "cost : " << kruskal();
inFile.close();
}
}
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.