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

Get windows cmd outputs



  • I have the following code:

    //this code run the ffmpeg code perfectly
    void MainWindow::on_pushButton_videoFormatConverter_clicked()
    {
        QStringList input = QFileDialog::getOpenFileNames();
        qDebug().noquote() << input[0];
    
        int lastForwardSlashIdx = input[0].lastIndexOf('/');
        int lastDotIdx = input[0].lastIndexOf('.');
    
        QString inputPath = input[0].left(lastForwardSlashIdx + 1);
        qDebug().noquote() << inputPath;
    
        QStringList inputFileName;
        QStringList inputFileExtension;
        for(int i = 0; i < input.size(); ++i) {
            inputFileName.push_back(input[i].mid(lastForwardSlashIdx + 1, lastDotIdx - lastForwardSlashIdx - 1));
            inputFileExtension.push_back(input[i].right(input[i].length() - lastDotIdx - 1));
            qDebug().noquote() << inputFileName[i];
            qDebug().noquote() << inputFileExtension[i];
        }
    
        QString outputPath = inputPath + "outputs";
        QDir outputFolder;
        outputFolder.mkpath(outputPath);
    
        QString ffmpegInput;
        QString ffmpegOutput;
        for(int i = 0; i < input.length(); ++i) {
            ffmpegInput += " -i \"" + inputPath + inputFileName[i] + "." + inputFileExtension[i] + "\" ";
            ffmpegOutput += " \"" + outputPath + "/" + inputFileName[i] + ".mkv\" ";
        }
    
        QString ffmpegCode = "ffmpeg " + ffmpegInput + ffmpegOutput;
        qDebug().noquote() << ffmpegCode;
    
    
        QProcess process;
        process.execute(ffmpegCode);
    
    }
    

    When I run the ffmpeg with win cmd I get outputs, it changes over time. I would like to get this output to a Qt textbox.

    cmd.PNG





  • readyReadStandardOutput() will do it.



  • and of course you already know that text uses <CR> only to overwrite the line as it updates? wreaks bloody havoc on processing wrapper scripts.


Log in to reply