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. QProcess failed to start on windows when cmd prompt works.
Qt 6.11 is out! See what's new in the release blog

QProcess failed to start on windows when cmd prompt works.

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 1.1k Views
  • 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.
  • aarelovichA Offline
    aarelovichA Offline
    aarelovich
    wrote on last edited by
    #1

    HI!

    When running this command from the command line prompt:

    magick convert report_pages/test_0.png report_pages/test_1.png report_pages/test_2.png report_pages/test.pdf
    

    It works perfectly. Generating a PDF from the three test png images. The location where I'm running this command is the location of the Qt Application compiled executable that I'm developing. This is a Windows application.

    I want to run that same command from said Qt application.

    In order to do this I use this code:

        QProcess pdfmerge;
        pdfmerge.start(PDF_GEN_APPLICATION,arguments);
        bool all_good = pdfmerge.waitForFinished();
    
        this->cmd = QString(PDF_GEN_APPLICATION) + " " + arguments.join(" ");
    

    Inside a class. PDF_GEN_APPLICATION is just a define for the string "magick convert".
    As a matter a fact I took the string that I run in the CMD console from the output of printing this->cmd.

    When I try to run the Qt Application I get the error that the process "Failed To Start". With no other clues, I was wondering if anyone here could help me. In order to run my Qt Application I just press play in QtCreator, in case that has anything to do with it.

    jsulmJ JonBJ 2 Replies Last reply
    0
    • aarelovichA aarelovich

      HI!

      When running this command from the command line prompt:

      magick convert report_pages/test_0.png report_pages/test_1.png report_pages/test_2.png report_pages/test.pdf
      

      It works perfectly. Generating a PDF from the three test png images. The location where I'm running this command is the location of the Qt Application compiled executable that I'm developing. This is a Windows application.

      I want to run that same command from said Qt application.

      In order to do this I use this code:

          QProcess pdfmerge;
          pdfmerge.start(PDF_GEN_APPLICATION,arguments);
          bool all_good = pdfmerge.waitForFinished();
      
          this->cmd = QString(PDF_GEN_APPLICATION) + " " + arguments.join(" ");
      

      Inside a class. PDF_GEN_APPLICATION is just a define for the string "magick convert".
      As a matter a fact I took the string that I run in the CMD console from the output of printing this->cmd.

      When I try to run the Qt Application I get the error that the process "Failed To Start". With no other clues, I was wondering if anyone here could help me. In order to run my Qt Application I just press play in QtCreator, in case that has anything to do with it.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @aarelovich said in QProcess failed to start on windows when cmd prompt works.:

      PDF_GEN_APPLICATION is just a define for the string "magick convert".

      This is wrong. The command is "magick", "convert" is a parameter and should be part of parameter list.
      Also add error handling to see what happens (see https://doc.qt.io/qt-5/qprocess.html#error, https://doc.qt.io/qt-5/qprocess.html#errorOccurred).

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • aarelovichA Offline
        aarelovichA Offline
        aarelovich
        wrote on last edited by
        #3

        Tried to move convert to be the first argument. But the error is the same. QProcess Error is "Failed To Start". It was a good idea, though.

        jsulmJ 1 Reply Last reply
        0
        • aarelovichA aarelovich

          Tried to move convert to be the first argument. But the error is the same. QProcess Error is "Failed To Start". It was a good idea, though.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @aarelovich Try to use full path to magick, not only "magick"

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          aarelovichA 1 Reply Last reply
          0
          • jsulmJ jsulm

            @aarelovich Try to use full path to magick, not only "magick"

            aarelovichA Offline
            aarelovichA Offline
            aarelovich
            wrote on last edited by
            #5

            @jsulm HI! Actually I think your first suggestion fixed it. Thing is its only failing now, If I run the application from QtCreator. If I run it as a stand alone it works. It didn't work before.

            So thank you!

            jsulmJ 1 Reply Last reply
            0
            • aarelovichA aarelovich

              @jsulm HI! Actually I think your first suggestion fixed it. Thing is its only failing now, If I run the application from QtCreator. If I run it as a stand alone it works. It didn't work before.

              So thank you!

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @aarelovich said in QProcess failed to start on windows when cmd prompt works.:

              its only failing now, If I run the application from QtCreator

              Probably it can't find "magick". If this is the case you can change PATH in the Run configuration for your project in QtCreator to add the folder containing "magick" to PATH.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              2
              • aarelovichA aarelovich

                HI!

                When running this command from the command line prompt:

                magick convert report_pages/test_0.png report_pages/test_1.png report_pages/test_2.png report_pages/test.pdf
                

                It works perfectly. Generating a PDF from the three test png images. The location where I'm running this command is the location of the Qt Application compiled executable that I'm developing. This is a Windows application.

                I want to run that same command from said Qt application.

                In order to do this I use this code:

                    QProcess pdfmerge;
                    pdfmerge.start(PDF_GEN_APPLICATION,arguments);
                    bool all_good = pdfmerge.waitForFinished();
                
                    this->cmd = QString(PDF_GEN_APPLICATION) + " " + arguments.join(" ");
                

                Inside a class. PDF_GEN_APPLICATION is just a define for the string "magick convert".
                As a matter a fact I took the string that I run in the CMD console from the output of printing this->cmd.

                When I try to run the Qt Application I get the error that the process "Failed To Start". With no other clues, I was wondering if anyone here could help me. In order to run my Qt Application I just press play in QtCreator, in case that has anything to do with it.

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #7

                @aarelovich said in QProcess failed to start on windows when cmd prompt works.:

                When I try to run the Qt Application I get the error that the process "Failed To Start". With no other clues,

                First attach to errorOccurred, as @jsulm wrote.
                Second attach to read any & all standard output/error, often there is a message on standard error.

                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