Results 1 to 2 of 2

Thread: executing a command in qt creator

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2015
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default executing a command in qt creator

    system("ls /home/jayachandra/ > file.txt"); this is getting done
    but if
    Qstring str="ls /home/jayachandra/ > file.txt";
    system(str); this is not getting done


    getting error like can't convert to constchar *
    Last edited by jayachandra reddy; 17th February 2015 at 06:17.

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: executing a command in qt creator

    "system()" function accepts const char * parameter, and there is no implicit conversion from QString to const char *.
    Convert the string to QByteArray and then extract the raw data from it.
    Btw. you don't have to use external process to do a directory listing, have a look at QDir class.

Similar Threads

  1. Replies: 4
    Last Post: 10th October 2014, 15:10
  2. executing g++ command with qt
    By saman_artorious in forum Qt Programming
    Replies: 9
    Last Post: 17th September 2013, 07:43
  3. Executing linux command as root
    By stefan in forum Qt Programming
    Replies: 1
    Last Post: 15th August 2011, 15:07
  4. Replies: 7
    Last Post: 15th November 2010, 09:00
  5. Could not find make command: (QT Creator)
    By heneedhelp in forum Installation and Deployment
    Replies: 1
    Last Post: 12th November 2010, 06:10

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.