Results 1 to 5 of 5

Thread: QProcess - quotes and spaces in parameters under Linux

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2010
    Posts
    9
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Question QProcess - quotes and spaces in parameters under Linux

    Hello,
    I'm trying to use ImageMagick with QProcess under Linux. The arguments are quite complicated, the whole command needed is for example:
    Qt Code:
    1. convert /tmp/temporaryPicture20.png -matte -virtual-pixel transparent -define distort:viewport=1105x3241+4572829+2684426 -distort Perspective '592,154 4572830,2684542 1408,54 4573934,2684426 654,2432 4572942,2687666 ' +repage /tmp/temporaryPicture20_out.png
    To copy to clipboard, switch view to plain text mode 
    Documentation suggests that such parameters may be tricky in Windows and Unix is piece of cake, but still I don't get how to use QProcess. What i tried was:
    a) puttin the whole command in QString and passing it to QProcess::start(QString) (without separate arguments)
    b)
    Qt Code:
    1. QString command = "convert";
    2. args
    3. <<"/tmp/mapin.png"
    4. <<"-matte"
    5. <<"-virtual-pixel"
    6. <<"transparent"
    7. <<"-define"
    8. <<"distort:viewport=1105x3241+4572829+2684426"
    9. <<"-distort"
    10. <<"Perspective"
    11. <<"'592,154 4572830,2684542 1408,54 4573934,2684426 654,2432 4572942,2687666'"
    12. <<"+repage"
    13. <<"/tmp/mapout.png";
    14. iProcess->start(command,args);
    To copy to clipboard, switch view to plain text mode 
    and some variations of b) (escaping spaces "\ ", escaping single quotes "\'", using double quotes instead of single ones and some other. In all cases finished(int,status) signal is emited with arguments 0,1 (1 is bad, right?), the output image is produced but not distorted according to -distort Perspective '(...)' , so (probably) some arguments are passed correctly, but this one is ignored as faulty.

    How do i pass it correctly?
    Last edited by mateuszzz88; 3rd July 2011 at 22:55. Reason: spelling corrections pointed out by SixDegrees

  2. #2
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QProcess - quotes and spaces in parameters under Linux

    The numeric argument to 'perspective' isn't properly quoted.

    I'd suggest using the variant that takes a single string argument. Then, you can print out the argument and examine it for errors, or simply try pasting it onto the command line to see if it runs as expected.

    Note, too, that you may not be able to assume a 'standard' environment when invoking processes this way. You may have to call setEnvironment to ensure that ImageMagick is able to find what it needs in order to run.
    Last edited by SixDegrees; 3rd July 2011 at 22:25.

  3. #3
    Join Date
    Jan 2009
    Location
    The Netherlands and Spain
    Posts
    150
    Thanks
    6
    Thanked 18 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QProcess - quotes and spaces in parameters under Linux

    Maybe you should split the numbers that are separated by spaces into separate args.

Similar Threads

  1. Replies: 8
    Last Post: 28th January 2015, 10:45
  2. qmake LIBS missing quotes
    By redoctober0 in forum General Programming
    Replies: 1
    Last Post: 12th January 2011, 17:05
  3. QSqlQuery and single quotes using bindValue
    By Luc4 in forum Qt Programming
    Replies: 4
    Last Post: 27th September 2010, 00:34
  4. Replies: 5
    Last Post: 4th February 2010, 00:50
  5. Replies: 1
    Last Post: 7th April 2008, 16:12

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.