How can I do so after saving it as CSV I open the file automatically

0
void MainWindow::on_btnExcell_clicked()
{
    QString done= "";
    tableView->setModel(mModel);
    QString path=QFileDialog::getSaveFileName(NULL,"Convertir a CSV","file","CSV(*.csv)");
    if(path.isEmpty())return;
    QFile file(path);
    if(!file.open(QIODevice::WriteOnly|QIODevice::Text)){
        return;
    }


    QTextStream Flux(&file);
    int i = 0;
    int j = 0;

    while(i<mModel->rowCount()){
        while(j<mModel->columnCount()){
            done+= tableView->model()->index(i,j).data().toString();
            if(j!=mModel->columnCount()){
                done+= ";";
            }
            j++;
        }
        done+= "\n";
        j=0;
        i++;
    }

    Flux << done;

    file.close();

    /* csv=QFileDialog::getOpenFileName(this,"abrir archivo",QDir::rootPath(),"*csv");
    QFile archivo(csv);
    if(!archivo.open(QIODevice::ReadOnly)){
        QMessageBox::critical(this,"Error",archivo.errorString());
        return;
    }
    archivo.readAll();*/
}

this code converts a table into csv once the .csv file is created, what I want is that the file created will be there next

    
asked by Antonio Veloso Gomez 15.05.2017 в 12:40
source

1 answer

0

With this I fixed what I was looking for:

QDesktopServices::openUrl(QUrl::fromLocalFile(path));
    
answered by 16.05.2017 в 09:55