#include#include int main() { QDir directory("path/to/directory"); QStringList fileNames = directory.entryList(QStringList() << "*.txt" << "*.xml", QDir::Files); qDebug() << "List of file names:"; for (const QString& fileName : fileNames) { qDebug() << fileName; } return 0; }
#includeThis code reads a CSV file and splits each line into fields using the comma delimiter. The fields are then joined with a tab separator and added to a list of rows. The rows are printed to the console for verification. In both examples, the Qt library package is required to use the StringList class.#include #include int main() { QFile file("path/to/csv/file.csv"); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { return 1; } QStringList rows; QTextStream in(&file); while (!in.atEnd()) { QString line = in.readLine(); QStringList fields = line.split(","); rows << fields.join("\t"); } qDebug() << "List of rows:"; for (const QString& row : rows) { qDebug() << row; } return 0; }