void NarutoMove::on_submitButton_clicked(){ logTextEdit->append("Copying start"); QString name; QString numChapter; if(!dirFrom.isEmpty()) { QDir d(dirFrom); logTextEdit->append(dirFrom); numChapter=getChapterNumber(d.dirName()); logTextEdit->append(numChapter); QStringList sl = d.entryList(QDir::Files); logTextEdit->append("d.entryList"); foreach(name,sl) { logTextEdit->append("Start foreach"); if (!name.startsWith("Credit"))//что бы копировать только главы { name="\\"+name; QFile f(dirFrom+name); f.copy(dirTo+name); logTextEdit->append(f.errorString()); logTextEdit->append(QString("copied %1 to %2").arg(dirFrom+name,dirTo+name)); } } }}
C++ (Qt) ... if (name.startsWith("Credit")) continue; QFileInfo infoFrom(dirFrom, name); QFileInfo infoTo(dirTo, name); QFile::copy(infoFrom.absoluteFilePath(), infoTo.absoluteFilePath()); ...}
C++ (Qt)foreach(QString name,sl)
foreach(name,sl) { logTextEdit->append("Start foreach"); if (!name.startsWith("Credit"))//что бы копировать только главы { //name="/"+name;// QFile f(dirFrom+name);// f.copy(dirTo+name)? logTextEdit->append(QString("copied %1 to %2").arg(dirFrom+name,dirTo+name)):// logTextEdit->append(f.errorString()); QFileInfo infoFrom(dirFrom, name); QFileInfo infoTo(dirTo, name); QFile::copy(infoFrom.absoluteFilePath(), infoTo.absoluteFilePath())? logTextEdit->append(QString("copied %1 to %2").arg(dirFrom+name,dirTo+name)): logTextEdit->append("error");; }
C++ (Qt)QLineEdit *lineEdit = qobject_cast<QLineEdit *>(sender());if (lineEdit){ // сравниваешь lineEdit с имеющимися}