Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QProcess with psql in linux



  • Hello everyone, I'm having a problem executing a command to load the database using QProcess.

    QStringList cmd;
    QString programa = "psql";
    cmd << QString("psql -d DBName < %1 ").arg(filePathAndName);
    QProcess process;
    process.start(programa, cmd);
    process.waitForFinished();
    qDebug()<<"out"<<process.readAll();

    What is wrong with my execution?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Your cmd variable content is wrong. Each parameter of the process should be passed as a separate instance.
    Also, why do you have cmd twice in the code base ?


Log in to reply