Results 1 to 3 of 3

Thread: Pass a QString as args for commandProcess

  1. #1
    Join Date
    Dec 2009
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Pass a QString as args for commandProcess

    Hi,

    I'm totally new to Qt, and I'm trying to create a simple frontend for the "mencoder" video encoder using Qt Creator.

    So, I use commandProcess to call "mencoder" and pass some parameters :

    Qt Code:
    1. args << "-ovc";
    2. args << "help";
    3. commandProcess.start("mencoder", args);
    To copy to clipboard, switch view to plain text mode 

    It works fine. Now what I don't understand is how to make this work :

    Qt Code:
    1. args << ui->lineEditInput->text();
    2. commandProcess.start("mplayer", args);
    To copy to clipboard, switch view to plain text mode 

    As you can see in the code, I want that a user typed string of parameters entered into a lineEdit will be passed as args for commandProcess.

    Any leads ?

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Pass a QString as args for commandProcess

    You must divide lineEditInput->text() into individual tokens because without that mencoder receives one argument. I.e. if user type "-ovc blabla bleble" You must send to mencoder 3 parameters : 1.-ovc 2.blabla 3.bleble. Now You are sending them one parameter "-ovc blabla bleble". This is not the same.

  3. #3
    Join Date
    Sep 2009
    Location
    Tashkent, Uzbekistan
    Posts
    107
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Pass a QString as args for commandProcess

    You can convert your args through QStringList and then submit the args using QString.to* methods. See assistant for details.

Similar Threads

  1. Qy 4.4.3 MySQL driver failed
    By pamalite in forum Installation and Deployment
    Replies: 2
    Last Post: 23rd January 2010, 02:09
  2. File rename detection
    By bunjee in forum Qt Programming
    Replies: 6
    Last Post: 23rd July 2009, 16:22
  3. Convert from iso-8859-1 to... Something else :-)
    By Nyphel in forum Qt Programming
    Replies: 4
    Last Post: 7th March 2007, 18:59
  4. How to pass a QString to another class ?
    By probine in forum Qt Programming
    Replies: 9
    Last Post: 9th December 2006, 21:16
  5. how can I pass a QString to vsnprintf?
    By coralbird in forum Newbie
    Replies: 6
    Last Post: 18th January 2006, 09:32

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.