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

run process with file between quote



  • Hello,

    I need to run command using process with command line below:

    "magick convert -density 300 -trim "E:/messages/filename" -quality 100 "e:/output.jpg";
    }
    

    then the problem is about double quote.

    I try to use escape :

       QDir directory("E:/messages");
       QStringList images = directory.entryList(QStringList(),QDir::Files);
       foreach(QString filename, images) {
    program="magick convert -density 300 -trim \"E:/messages/" +filename+"\" -quality 100 \"e:/output.jpg\"";
    }
    

    but the output give:

    "magick convert -density 300 -trim \"E:/messages/test.pdf\" -quality 100 \"e:/output.jpg\""
    

    and then process is not working...

    could you help me?

    kind regards


  • Lifetime Qt Champion

    Hi
    Instead of making one big string with both program and parameters, QProcess excepts you to use a list.
    http://doc.qt.io/qt-5/qprocess.html

        QString program = "./path/to/Qt/examples/widgets/analogclock";
        QStringList arguments;
        arguments << "-style" << "fusion";
    
        QProcess *myProcess = new QProcess(parent);
        myProcess->start(program, arguments); // notice program and parameters are separate.
    


  • great thanks a lot


Log in to reply