Hi,
I'm learning to use Qt.
I have to read all XML file existing in a directory.
The code I wrote works well with a single file, but I would have results about all the directory.
Could you suggest me the code that I'd have to paste in my .cpp file that allow me to open a QDialog with the choice of the directory and to select a file per time to read?
Now that piece of code is:
bool DomParser::readFile()
{
QFileDialog::getOpenFileName(this, tr
("Open Gate File"),
tr("XML Files (*.xml)"));*/
qDebug() << fileName;
if (fileName.isEmpty())
return false;
tr("Cannot read file %1:\n%2.")
.arg(fileName)
.arg(file.errorString()));
return false;
}
qDebug() << "file opened"; ....
bool DomParser::readFile()
{
QString fileName =
QFileDialog::getOpenFileName(this, tr("Open Gate File"),
QDir::currentPath(),
tr("XML Files (*.xml)"));*/
qDebug() << fileName;
if (fileName.isEmpty())
return false;
QFile file(fileName);
if (!file.open(QFile::ReadOnly | QFile::Text)) {
QMessageBox::warning(this, tr("SAX Bookmarks"),
tr("Cannot read file %1:\n%2.")
.arg(fileName)
.arg(file.errorString()));
return false;
}
qDebug() << "file opened"; ....
To copy to clipboard, switch view to plain text mode
This, as I explained, allow me to choose the file and read it. Relevant information will be write into another file so I need all info from all files.
Thank to all.
Please help me!
Bookmarks