I check if the info of the file exists. It does not, it says that the file doesn’t exist but as soon as i delete the check line the filename is printed onto the QTableView.
(the file exists in the dictionary)
void printOutput(std::set<std::string> files, QStandardItemModel* model)
{
model->setRowCount(files.size());
int row = 0;
for (const auto& str : files)
{
const auto fname = QString::fromStdString(str);
QFileInfo info(fname);
if (!info.exists())
{
QMessageBox::warning(nullptr, "printOutput", QString("%1 don't exist").arg(fname));
continue;
}
const auto dateTime = info.lastModified();
auto* dateItem = new QStandardItem(dateTime.toString());
auto* fileItem = new QStandardItem(fname);
model->setItem(row, 0, dateItem);
model->setItem(row, 1, fileItem);
row++;
}
}
I added the if-statement to check whether there is a info for the file. I expected it to go through and print the info (Date & Time of last modification). But the QMessageBox with the warning got shown.
user26432708 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.