Unix command slot creation
-
"QProcess":http://developer.qt.nokia.com/doc/qt-4.7/qprocess.html should be your friend here.
-
"QDir":http://doc.qt.nokia.com/4.7/qdir.html#current might be a better option for your example command. But in general, sierdzio is right.
-
I think you should avoid to create such a slot. The beauty of Qt is that the library is platform independent, so if you need to get runtime informations such as the working directory or alike you should use the library services, and not platform specific commands that are going to tie your application to a specific execution environment.
-
I strongly suggest to avoid running processes like the above directly, or your application will be strictly tied to the unix environment, and maybe to a linux one!
Use QFile for managing copies, QDir for managing paths and classes alike as much as you can. -
fluca1978, I think you're overreacting a little bit. phani448 seems to have already chosen their way of doing it. It is, of course, possible to use native tools on all platforms by simply specifying different names for tools, depending on the host OS (Qt has a set of OS related #defines that can be used here), and it will work just as well. It might not be the best option in your view (mine too, in fact, at least when it comes to trivial stuff like cp -r or pwd), but the subject here revolves around HOW to run native commands, not WHETHER to use them.
-
[quote author="fluca1978" date="1317638423"]Sorry, I was not saying it is absolutely a bad idea to use QProcess, but that it could be a bad idea for a lot of cases where Qt already provides a wrapping for doing the same task. [/quote]
And you're perfectly right here :) Cheers.