am having zip file in server while i downloading i have to unzip the file using qt..still i dont get proper solution for this
qt experts can any one give me suggestion for this
Tahnks in advance
am having zip file in server while i downloading i have to unzip the file using qt..still i dont get proper solution for this
qt experts can any one give me suggestion for this
Tahnks in advance
Use QProcess to run gunzip.
Or use KArchive http://inqlude.org/libraries/karchive.html
Cheers,
_
iswaryasenthilkumar (23rd March 2015)
Did the QProcess start/run?
Did you connect the started(), finished(), and error() signals? Did any of the signals fire?
What was the exit code and exit status for your QProcess?
Answer these questions and post some code using [code][/code] tags please.
this was my code
what am doing wrong please guide meQt Code:
#include "widget.h" #include "ui_widget.h" #include<QtGui> ui(new Ui::Widget) { QStringList arguments; connect (myProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(printOut())); connect (myProcess, SIGNAL(readyReadStandardError()), this, SLOT(printError())); myProcess->start(program, arguments); myProcess->waitForFinished(); ui->setupUi(this); } Widget::~Widget() { delete ui; } void Widget::printOut() { { qDebug()<<line<<"Outputline"; } } void Widget::printError() { { qDebug()<<"Errorline"<<line; } }To copy to clipboard, switch view to plain text mode
First, you are setting the program to the zip file. Aren't you attempting to run program gunzip instead? The file name of your zip file should be one of the arguments you pass to the gunzip program.
What is the return code from waitForFinished? If you are not going to use the started, finished, and error signals, then you should also waitForStarted() after you start the QProcess and check its return code as well.
Edit: The waitFor* methods will block until they either timeout or the condition is satisfied, so if you are doing this from your GUI thread, your GUI will freeze, which is why I recommend you use the started, finished, and error signals instead.
Last edited by jefftee; 24th March 2015 at 05:29.
iswaryasenthilkumar (24th March 2015)
QString program = " " //this should contain path of the program??
QStringList arguments;
arguments=" " // this should contain path of the zip file??
Added after 5 minutes:
i have doubt in above i mentioned code.. what is meaning for this line arguments << "-style" << "motif";Qt Code:
QStringList arguments; arguments << "-style" << "motif"; myProcess->start(program, arguments);To copy to clipboard, switch view to plain text mode
waht ia have to mention in QString program = "./path/to/Qt/examples/widgets/analogclock";
Last edited by iswaryasenthilkumar; 24th March 2015 at 05:34.
Yes, program is the executable you wish to run and the arguments contain the arguments you are going to pass to the program. In the example below, /usr/bin/gunzip is the program and the file path is the argument:
You might want to pass other arguments to gunzip like:Qt Code:
/usr/bin/gunzip /some/path/to/your/zip/fileTo copy to clipboard, switch view to plain text mode
Where -v is the first argument and the file path is the 2nd agrument, etc. Pretty much exactly what you would type on the command line.Qt Code:
/usr/bin/gunzip -v /some/path/to/your/zip/fileTo copy to clipboard, switch view to plain text mode
Edit: The example you cited from the QProcess documentation runs a program called analogclock and passes arguments -style and motif, which for Qt GUI programs, tells Qt which style to use for the GUI. Since you are trying to run gunzip, you need to pass arguments to gunzip that make sense to gunzip. Run gunzip -h from the command line and see what arguments it understands, etc.
iswaryasenthilkumar (24th March 2015)
Thank you so much jthomps..soon i will implement the Qprocess concept
/usr/bin/gunzip...i checked in my terminal.. i getting error no file or directory for gunzip..is there any files to download for gunzip
try "which gunzip".... if it's installed and in your PATH, it will be found. If not, you'll need to figure out how to install gunzip and make it available for your operating system.
iswaryasenthilkumar (24th March 2015)
Try unzip instead of "gunzip". "gunzip" is, most likely, a Gnome utility (guessing from the prefix "g"). If you have KDE or LXDE then you have no "gunzip". First, open your package downloader and check whether unzip is installed. If it is, replace "gunzip" by "unzip" in your code.
If you have KDE, the better solution is using KZip and KArchiveEntry objects from libkdecore. libkdecore manual is at api.kde.org
Or try this library
AFAIK, libkarchive wasn't released as a stand-alone library. You need source (available at GIT) and compile. Or my information is slightly outdated Nevertheless, assuming KDE, libkdecore is already in use so that linking libkdecore is almost no overhead. libkarchive is a part of libkdecore.
Naturally, if we speak a KDE-independent Qt app, then downloading libkarchive and compiling is the right solution. It solves all problems with unzip, gunzip, what was installed and what wasn't, and so on.
gzip was installed in my linux bt i couldn't find out were it was placed
First release was July 7th, 2014
https://www.kde.org/announcements/kd...eworks-5.0.php
The main questions is: why on earth is a ZIP file again gzipped?
Cheers,
_
i wriiten code
the program executed bt i dont get any result i get " " this output..actually i missing something i need after reading this zipfile i need to extract the zip file.. give some idea to implementQt Code:
QStringList arguments; arguments<<" /home/digital_images/Desktop/zipfile.zip.gz"; // this was my zipfile path myProcess->start(program,arguments); qDebug()<<result;To copy to clipboard, switch view to plain text mode
Thanks in advance
Bookmarks