MyVector [i][j]=1 строка файла.
int j=0; while (!file2.atEnd()){j++;qDebug()<<j;}
QFile file1("Test.dat"); file1.open(QIODevice::ReadOnly | QIODevice::Truncate | QIODevice::Text); QDataStream in1(&file1); int i=0; while (!file1.atEnd()) { ++i; qDebug<<i; } file1.close();
QFile file2("Text.txt"); file2.open(QIODevice::ReadOnly | QIODevice::Truncate | QIODevice::Text); QTextStream in2(&file2); int j=0; while (!file2.atEnd()) { ++j; qDebug()<<j; } file2.close();
C++ (Qt)if (file.open(...)){ // файл открылся успешно, делаем что надо}else{ // можно сообщить об ошибке}
QFile file2("Text.txt"); if (file2.open(QIODevice::ReadOnly | QIODevice::Truncate | QIODevice::Text)) { QTextStream in2(&file2); int j=0; while (!in2.readLine().isNull()) { GlobalVaribles::QuestionAndAnswer.resize(j+1); GlobalVaribles::QuestionAndAnswer[j].resize(1); GlobalVaribles::QuestionAndAnswer[j][0]=in2.readLine(); qDebug()<<GlobalVaribles::QuestionAndAnswer[j][0]; for (int k=1;k=GlobalVaribles::all[j][1];k++) { GlobalVaribles::QuestionAndAnswer[j].resize(1+GlobalVaribles::all[j][1]); GlobalVaribles::QuestionAndAnswer[j][k]=in2.readLine(); qDebug()<<GlobalVaribles::QuestionAndAnswer[j][k]; } ++j; //qDebug()<<j; } file2.close(); } else QMessageBox::warning(0,tr("Warning"),tr("File not exists"),QMessageBox::Ok|QMessageBox::NoButton);}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" content="1" /><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">werwer</p></body></html><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" content="1" /><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">www</p></body></html><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" content="1" /><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">qweq</p></body></html><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" content="1" /><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">qweqwe</p></body></html><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" content="1" /><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">qwertyu</p></body></html>