• 2880阅读
  • 0回复

[提问]请问这个QTextStream的问题怎么解决 [复制链接]

上一主题 下一主题
离线闪电球
 

只看楼主 正序阅读 楼主  发表于: 2016-01-07
QMessageBox::warning(this, tr("Application"),                             tr("Cannot read file %1:\n%2.")                             .arg(fileName)                             .arg(file.errorString()));
  1. QString path = QFileDialog::getOpenFileName(this);
  2.     if(!path.isEmpty())
  3.     {
  4.         QFile file(path);
  5.         if(!file.open(QFile::ReadOnly | QFile::Text))
  6.         {
  7.             QMessageBox::warning(this, tr("Application"),
  8.                                  tr("Cannot read file %1:\n%2.")
  9.                                  .arg(path)
  10.                                  .arg(file.errorString()));
  11.             return ;
  12.         }
  13.         QTextStream in(&file);
  14.         theEdit->setText(in.readAll());
  15.         file.close();
  16.     }
  17.     else
  18.     {
  19.         ;
  20.     }
为什么总是有上面的报错呢?求解答
快速回复
限100 字节
 
上一个 下一个