QMessageBox::warning(
this,
tr(
"Application"),
tr(
"Cannot read file %1:\n%2.")
.arg(fileName)
.arg(file.errorString()));
- QString path = QFileDialog::getOpenFileName(this);
- if(!path.isEmpty())
- {
- QFile file(path);
- if(!file.open(QFile::ReadOnly | QFile::Text))
- {
- QMessageBox::warning(this, tr("Application"),
- tr("Cannot read file %1:\n%2.")
- .arg(path)
- .arg(file.errorString()));
- return ;
- }
- QTextStream in(&file);
- theEdit->setText(in.readAll());
- file.close();
- }
- else
- {
- ;
- }
为什么总是有上面的报错呢?求解答