hmmm.... it seems the problem is QStringList results have nothing in it? Hopefully im right
And when i use canReadLine(), the program actually outputted cant read line
result << "Something" << "abc";
QFile input
("configp.dll");
if(input.canReadLine()){
ui->hLine->setText("can read");
}else{
//EDITED : removed this line QApplication::processEvents();
ui->hLine->setText("cant read line"); //outputted this " can't read line "
}
while (!input.atEnd()){
QByteArray line
= input.
readLine().
simplified();
//trimmed to simplified QString foo;
//actually which line of code chris provided converted ascii numbers to char?
foo.
append( QChar(num.
toShort()) );
// is it this .toShort? }
result << foo;// if use line->setText() here also output same..
}
ui->aLine->setText(result.at(0)); // this output Something
ui->fLine->setText(result.at(1)); //this output abc not anything from the file
QStringList result;
result << "Something" << "abc";
QFile input("configp.dll");
if (input.open(QIODevice::ReadOnly )) {
if(input.canReadLine()){
ui->hLine->setText("can read");
}else{
//EDITED : removed this line QApplication::processEvents();
ui->hLine->setText("cant read line"); //outputted this " can't read line "
}
while (!input.atEnd()){
QByteArray line = input.readLine().simplified(); //trimmed to simplified
QString foo; //actually which line of code chris provided converted ascii numbers to char?
foreach(QByteArray num, line.split(' ')) {
foo.append( QChar(num.toShort()) ); // is it this .toShort?
}
result << foo;// if use line->setText() here also output same..
}
ui->aLine->setText(result.at(0)); // this output Something
ui->fLine->setText(result.at(1)); //this output abc not anything from the file
To copy to clipboard, switch view to plain text mode
Edited : if i add these code below, it actually shows "can read"
char c;
input.getChar(&c);
if(input.canReadLine()){
ui->hLine->setText("can read");
}else{
ui->hLine->setText("cant read line");
}
if (input.open(QIODevice::ReadOnly )) {
char c;
input.getChar(&c);
if(input.canReadLine()){
ui->hLine->setText("can read");
}else{
ui->hLine->setText("cant read line");
}
To copy to clipboard, switch view to plain text mode
EDITED: AND HEY, AFTER HOURS OF CODING, I MANGED TO LET IT shows up on aLine But (didn't know i put it inside while loop)after showing up, it still goes runtime error, so i guess i gonna figure out what wysota(hope i spell it correct) is saying
EDITED: I actually found i duplicated settext that caused error. it's working now but figuring out how to output only available line. By the way, will moderator ban for too many edits?
I still have some problems with rename. qdir wont work too
EDITED: it now shows runtime error again.
EDITED: i actually jumped setText() from 0 to 3 where i only wanna jump 0 to 2, NOTE the rename still doesn't work 
QFile chk
("configp.dll");
if(chk.exists()){
QFile exs
("configp1.dll");
exs.remove(); //this can delete, works very well
chk.rename("configp1.dll"); // it wont rename
}else{
QFile chk("configp.dll");
chk.open(QIODevice::ReadOnly);
if(chk.exists()){
QFile exs("configp1.dll");
if(exs.open(QIODevice::ReadOnly))
exs.remove(); //this can delete, works very well
chk.rename("configp1.dll"); // it wont rename
}else{
To copy to clipboard, switch view to plain text mode
Bookmarks