PDA

View Full Version : executing a command in qt creator



jayachandra reddy
17th February 2015, 07:08
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 *

stampede
17th February 2015, 08:11
"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.