Results 1 to 6 of 6

Thread: running a cmd command using Qt

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,349
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    318
    Thanked 872 Times in 859 Posts

    Default Re: running a cmd command using Qt

    How many times does this same question have to be answered in this forum?

    If you want to run a command with command line parameters using QProcess, you have to give QProcess::start() or QProcess::startDetached() at least two arguments: a QString containing the command to be executed and a QStringList containing the parameters to the command:

    Qt Code:
    1. QString command( "cmd.exe" );
    2. QStringList params = QStringList() << "/k" << "ping" << "1.1.1.1" << "-n" << ... and so forth
    3.  
    4. QProcess::startDetached( command, params );
    To copy to clipboard, switch view to plain text mode 

    QProcess::startDetached() is a static method, therefore no QProcess instance is required.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  2. The following user says thank you to d_stranz for this useful post:

    anda_skoa (3rd March 2017)

Similar Threads

  1. How to Send a command to already running process
    By Rajvesh in forum Qt Programming
    Replies: 2
    Last Post: 21st February 2017, 05:02
  2. read output of command running though ssh
    By Cbr89 in forum Qt Programming
    Replies: 1
    Last Post: 31st January 2017, 07:06
  3. Replies: 2
    Last Post: 7th April 2015, 08:18
  4. Replies: 2
    Last Post: 28th May 2010, 09:16
  5. running shell command from C++ code problem
    By alex chpenst in forum Qt Programming
    Replies: 4
    Last Post: 31st July 2008, 10:41

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
  •  
Qt is a trademark of The Qt Company.