Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Get windows cmd outputs

Get windows cmd outputs

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 341 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    ekato993
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      https://doc.qt.io/qt-5/qprocess.html#communicating-via-channels

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      5
      • JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by
        #3

        readyReadStandardOutput() will do it.

        1 Reply Last reply
        1
        • Kent-DorfmanK Offline
          Kent-DorfmanK Offline
          Kent-Dorfman
          wrote on last edited by
          #4

          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.

          If you meet the AI on the road, kill it.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved