QString dbg; dbg=currentDir.currentPath() + "/" + ui->comboFile->currentText(); qDebug() << dbg; QFile target(dbg); target.open(QIODevice::ReadOnly); qDebug()<< target.permissions(); if (target.open(QIODevice::ReadOnly)) { return; } else { QByteArray array(target.read(20)); char data[25]; int d=1; while (d<10) { qDebug()<< array.size(); data[d] = array.at(d); qDebug() << data[d]; } }
QString dbg; dbg=currentDir.currentPath() + "/" + ui->comboFile->currentText(); qDebug() << dbg; QFile target(dbg); target.open(QFile::ReadOnly); QByteArray array(target.read(20)); char data[25]; int d=0; while (d<10) { qDebug()<< array.size(); data[d] = array.at(d); qDebug() << data[d]; d++; }
if (!target.open(QIODevice::ReadOnly)); qDebug()<< "not open";
bool b=0; b=target.open(QIODevice::ReadOnly); qDebug()<<b;
void MainWindow::OpenDi(){ ui->textEdit->clear(); ui->comboFile->clear(); QFileDialog di; QString str = di.getExistingDirectory(0,"dialog",""); qDebug()<< str; currentDir.setPath(str); QFileInfoList list = currentDir.entryInfoList(); di.show(); for (int i = 0; i < list.size(); ++i) { QFileInfo fileInfo = list.at(i); ui->textEdit->append(fileInfo.fileName()); } ui->comboFile->addItems(currentDir.entryList());}
QString dbg=strCurDir + "/" + ui->comboFile->currentText(); // В dbg полный путь с именем файла. qDebug() << dbg; // Вывод - "/home/exp/67563.61339.dat" QFile target(dbg); bool b=0; b=target.open(QIODevice::ReadOnly); qDebug()<<b; // Вывод - false qDebug()<< target.size(); // Вывод - 0