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 not accepting arguments in MacOS (works in Windows)
QtWS25 Last Chance

QProcess not accepting arguments in MacOS (works in Windows)

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 4 Posters 1.7k 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.
  • R Offline
    R Offline
    Rory_1
    wrote on last edited by
    #1

    I am running Qt 5.10 on MacOS 10.13.2

    I am trying to open photoshop with one or more selected images in MacOS. In terminal this works:

    open "/Users/roryhill/Pictures/4K/2017-01-25_0030-Edit.jpg" -a "Adobe Photoshop CS6"
    

    The following works in Windows but not MacOS:

    QString app = "\"/Applications/Adobe Photoshop CS6/Adobe Photoshop CS6.app\"";  // diff file path for windows
    QStringList arguments;
    arguments << "/Users/roryhill/Pictures/4K/2017-01-25_0030-Edit.jpg";
    QProcess *process = new QProcess();
    process->start(app, arguments);
    

    In MacOS I get the error: "FailedToStart". If I drop the arguments in the last line and use:

    process->start(app);
    

    then photoshop opens, so the path to the photoshop executable is working.

    I have also tried using the executable inside the app container:

    "/Applications/Adobe Photoshop CS6/Adobe Photoshop CS6.app/Contents/MacOS/Adobe Photoshop CS6"
    

    Again this works to open photoshop but fails when arguments are added.

    This also fails:

    process->setArguments(arguments);
    process->setProgram(app);
    process->start();
    

    Omitting setArguments() fails too using this procedure:

    process->setProgram(app);
    process->start();
    

    Could this be some permissions issue in MacOS?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      What happens if you do ?
      QDesktopServices::openUrl(QUrl("file:///Users/roryhill/Pictures/4K/2017-01-25_0030-Edit.jpg"));

      R 1 Reply Last reply
      0
      • mrjjM mrjj

        Hi
        What happens if you do ?
        QDesktopServices::openUrl(QUrl("file:///Users/roryhill/Pictures/4K/2017-01-25_0030-Edit.jpg"));

        R Offline
        R Offline
        Rory_1
        wrote on last edited by
        #3

        @mrjj said in QProcess not accepting arguments in MacOS (works in Windows):

        QDesktopServices::openUrl(QUrl("file:///Users/roryhill/Pictures/4K/2017-01-25_0030-Edit.jpg"));

        That opens the image in preview, so I guess permissions are okay.

        R 1 Reply Last reply
        0
        • R Rory_1

          @mrjj said in QProcess not accepting arguments in MacOS (works in Windows):

          QDesktopServices::openUrl(QUrl("file:///Users/roryhill/Pictures/4K/2017-01-25_0030-Edit.jpg"));

          That opens the image in preview, so I guess permissions are okay.

          R Offline
          R Offline
          Rory_1
          wrote on last edited by
          #4

          @Rory_1

          If I change the executable to preview:

          app = "/Applications/Preview.app";
          

          then it all works as expected, so the issue seems to be with photoshop. I have also tried the latest version of photoshop with the same issues.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mpergand
            wrote on last edited by
            #5

            try to use open.

            open -b org.mozilla.firefox "Samsung A3 2017.pdf"
            

            open the pdf file with Firefox
            (I don't have photoshop)
            Tape "man open" in the Terminal for details.

            R 1 Reply Last reply
            0
            • M mpergand

              try to use open.

              open -b org.mozilla.firefox "Samsung A3 2017.pdf"
              

              open the pdf file with Firefox
              (I don't have photoshop)
              Tape "man open" in the Terminal for details.

              R Offline
              R Offline
              Rory_1
              wrote on last edited by
              #6

              @mpergand said in QProcess not accepting arguments in MacOS (works in Windows):

              try to use open.

              open -b org.mozilla.firefox "Samsung A3 2017.pdf"
              

              open the pdf file with Firefox
              (I don't have photoshop)
              Tape "man open" in the Terminal for details.

              Thanks. I will try this. I have to take a family break and I will report back tomorrow.

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Hi,

                You'll likely have to use the full path to the executable within the application bundle rather than the bundle itself.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                R 1 Reply Last reply
                0
                • SGaistS SGaist

                  Hi,

                  You'll likely have to use the full path to the executable within the application bundle rather than the bundle itself.

                  R Offline
                  R Offline
                  Rory_1
                  wrote on last edited by
                  #8

                  @SGaist said in QProcess not accepting arguments in MacOS (works in Windows):

                  Hi,

                  You'll likely have to use the full path to the executable within the application bundle rather than the bundle itself.

                  Thanks for the suggestion. As I mentioned in my original post I have tried this and it did not work.

                  I think my issue is related to how MacOS manages file locks. I can get the code to work with preview once and then the next time I get an error "the file couldn’t be opened because you don’t have permission to view it." This seems to be a common problem where preview maintains a lock on the file after the application has been closed. I'm going to take a look at QLockFile to see if it can help.

                  R 1 Reply Last reply
                  0
                  • R Rory_1

                    @SGaist said in QProcess not accepting arguments in MacOS (works in Windows):

                    Hi,

                    You'll likely have to use the full path to the executable within the application bundle rather than the bundle itself.

                    Thanks for the suggestion. As I mentioned in my original post I have tried this and it did not work.

                    I think my issue is related to how MacOS manages file locks. I can get the code to work with preview once and then the next time I get an error "the file couldn’t be opened because you don’t have permission to view it." This seems to be a common problem where preview maintains a lock on the file after the application has been closed. I'm going to take a look at QLockFile to see if it can help.

                    R Offline
                    R Offline
                    Rory_1
                    wrote on last edited by
                    #9

                    @Rory_1 Update: I have partially solved my problem by resetting permissions on my macbook.

                    diskutil resetUserPermissions / `id -u`
                    

                    The code now works consistently for all applications, including adobe Bridge, except photoshop. I assumed (bad plan) that photoshop accepted command line arguments (and it does in windows) but might not in MacOS.

                    I do not believe the remaining issues are related to QProcess so I am marking this as solved.

                    Thanks to @SGaist, @mpergand and @mrjj for your assistance!

                    1 Reply Last reply
                    1

                    • Login

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