Qt Application with CLI Commands
-
There's a ton of information regarding Qt. It's one of the most well documented toolkits around. I'm not sure where you've been looking. Have you tried the "QProcess":http://developer.qt.nokia.com/doc/qt-4.8/qprocess.html docs?
Here's a brief example lifted directly from those docs. I don't know the command line parameters for 7z, but it should work the same as this example below. Just substitute the 7z executable for "analogclock" and use the proper command line parameters that are expected. Not a difficult exercise.
@
QObject *parent;
...
QString program = "./path/to/Qt/examples/widgets/analogclock";
QStringList arguments;
arguments << "-style" << "motif";QProcess *myProcess = new QProcess(parent); myProcess->start(program, arguments);@
-
Quite simple indeed. Can I hide the command prompt or software interface while this is taking place? I do not want the user to see that a 3rd party application is behind this...
-
Those arguments seem a little tricky...How's the order they should be written? For example the command line command for 7z is "7za a -t7z files.7z text1.txt" to create files.7z with text1.txt inside.
@QApplication a(argc, argv);
QObject *parent; QString program = "C:\Software\7za920\7za.exe"; QStringList arguments; arguments << "7za a -t7z files.7z text1.txt"; QProcess *myProcess = new QProcess(parent); myProcess->start(program, arguments); zipfile w; w.show(); return a.exec();@ -
Hmm...done but it doesn't work...but where do we specify where the .txt file is located? How does the program know where to get it from?
-
Still...
@QObject *parent;
QString program = "/Software/7za920/7za.exe";
QStringList arguments;
arguments << "a" << "-t7z" << "/Users/croussou_dm4/Desktop/files.7z" << "/Users/croussou_dm4/Desktop/text1.txt";
QProcess *myProcess = new QProcess(parent);
myProcess->start(program, arguments);@By the way, thanks for your support...
-
I'd suggest reading through the docs for QProcess. There are various ways to find the return code of the finished process (was it ok?) or to read from stderr (were there any error messages), and that sort of thing.
In the long run, it will be much more beneficial than me or anyone else trying to guess what the problems may be.
By the way, you're welcome!
-
Again thank you very much.
I will look into that.