Results 1 to 5 of 5

Thread: running shell command from C++ code problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2008
    Posts
    69
    Thanks
    9
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: running shell command from C++ code problem

    How could we adjust this code to windows command?
    should we replace /bin/sh with win32 or something?

    thanks
    SunnySan

  2. #2
    Join Date
    Apr 2007
    Location
    Ilsfeld, Germany
    Posts
    16
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: running shell command from C++ code problem

    Hi,

    use cmd.exe with /c

    Qt Code:
    1. QStringList arguments;
    2. arguments << "/c dir /b e:\\test\\*.txt | sort";
    3. QProcess exec;
    4. exec.start("cmd.exe", arguments);
    5. exec.waitForFinished();
    6. qDebug() << exec.readAllStandardOutput();
    To copy to clipboard, switch view to plain text mode 
    HTH, Bernd

Similar Threads

  1. problem with linking
    By mickey in forum Qt Programming
    Replies: 49
    Last Post: 12th August 2006, 21: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.