Creating text file with Qt Creator on embedded Linux

208 Views Asked by At

I'm trying to create a text file by clicking on a button as following code, but I'm not getting.

QString local = "/local/flash/root";
QString name = " ProductionOrder.txt";    

    void page1000::on_pushButton_3_clicked()
    {
        QFile file(local+name);
        if(!file.open(QFile::WriteOnly|QFile::Text)){
            QMessageBox::warning(this,"ERROR","Error open file");
        }
        QTextStream output(&file);
        QString text=ui->plainTextEdit->toPlainText();
        output << text;
        file.flush();
        file.close();
    }

what could be wrong with the code?

I am working with Qt 4.8

I don't know what to do

1

There are 1 best solutions below

0
On

just put "/" at the end of the QString local

Like this: QString local = "/local/flash/root/";