QT获取文件路径

QString file_path = QFileDialog::getOpenFileName(nullptr, tr("Import File"), "/", "txt(*txt)");
QFile txt_file(file_path);
if(txt_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
    QByteArray line = txt_file.readLine();
    QString params(line);
    QStringList params_list = params.replace(QStringLiteral(","), ",").split(",");
    if(params_list.count() == 28) {
      QVariantList double_list;
      for(int i = 0; i < 28; i ++) {
          double_list.append(params_list.at(i).toDouble());
      }
      setDHToSpn(double_list);
    }
}

 

你可能感兴趣的:(QT,C++)