다른 파일에서 동시에 여러 파일 (임의 번호) 파일을 열고 qlist에 텍스트 스트림을 저장하려고합니다.QT : QList에 QTextStream 저장
QList<QTextStream> files;
QList<QString> fnames;
fnames.append("file1.txt");
fnames.append("file2.txt");
// ..and so on with random iterations
// collect qtextsrams into qlist
foreach (QString file, fnames) {
QFile f(file);
f.open(QIODevice::ReadOnly);
QTextStream textStream(&f);
files2.append(&textStream);
}
// use qtextstreams in a loop
QList<QTextStream>::iterator i;
for (i = files.begin(); i != files.end(); ++i) {
qDebug() << i->readLine();
}
그래서 오류가 있습니다 :
/make debug
make -f Makefile.Debug
make[1]: Entering directory `/home/pixx/Workspace/collocs'
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -Idebug -o debug/main.o main.cpp
main.cpp: In function ‘int main(int, char**)’:
main.cpp:128: error: no matching function for call to ‘QList<QTextStream>::append(QTextStream*)’
/usr/include/qt4/QtCore/qlist.h:493: note: candidates are: void QList<T>::append(const T&) [with T = QTextStream]
/usr/include/qt4/QtCore/qlist.h:819: note: void QList<T>::append(const QList<T>&) [with T = QTextStream]
main.cpp:117: warning: unused variable ‘cc’
In file included from /usr/include/qt4/QtCore/QList:1,
from main.cpp:1:
/usr/include/qt4/QtCore/qtextstream.h: In member function ‘void QList<T>::node_copy(QList<T>::Node*, QList<T>::Node*, QList<T>::Node*) [with T = QTextStream]’:
/usr/include/qt4/QtCore/qlist.h:695: instantiated from ‘void QList<T>::detach_helper(int) [with T = QTextStream]’
/usr/include/qt4/QtCore/qlist.h:709: instantiated from ‘void QList<T>::detach_helper() [with T = QTextStream]’
/usr/include/qt4/QtCore/qlist.h:126: instantiated from ‘void QList<T>::detach() [with T = QTextStream]’
/usr/include/qt4/QtCore/qlist.h:254: instantiated from ‘QList<T>::iterator QList<T>::begin() [with T = QTextStream]’
main.cpp:133: instantiated from here
/usr/include/qt4/QtCore/qtextstream.h:258: error: ‘QTextStream::QTextStream(const QTextStream&)’ is private
/usr/include/qt4/QtCore/qlist.h:386: error: within this context
/usr/include/qt4/QtCore/qtextstream.h:258: error: ‘QTextStream::QTextStream(const QTextStream&)’ is private
/usr/include/qt4/QtCore/qlist.h:399: error: within this context
make[1]: Leaving directory `/home/pixx/Workspace/collocs'
make[1]: *** [debug/main.o] Error 1
make: *** [debug] Error 2
내가 고쳐야 할까? 나는 그것이 아주 간단한 질문 인 것을 이해한다, 그러나 google를위한 적당한 질문을 찾아 낼 수 없다 : (
아마도 내 초기 문제에 대한 더 간단한 해결책이 있을까요? 난 파일의 무작위 번호를 열고 그 후 다시 열지 않고 그들 중 일부에서 단일 라인을 읽을 필요가있다. – pixx
병합 순서가 지정된 파일을 하나로 통합하는 알고리즘이 필요합니다 : // N 개의 결과 파일 열기 // 각 파일의 행을 읽습니다. // - 두 파일을 모두 읽을 때까지 : // - 단어입니다. 동일? // - 예 -> 출력 파일에 단어와 합계를 씁니다. // 두 파일에서 다음 행을 읽습니다. // - 아니요 - 알파벳으로 가장 낮은 단어 만 출력합니다. // 읽기 이 단어의 결과 파일의 다음 줄 – pixx