Page 1 of 3 123 LastLast
Results 1 to 20 of 41

Thread: how to unzip the file in qt using gzip

  1. #1
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default how to unzip the file in qt using gzip

    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

  2. #2
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: how to unzip the file in qt using gzip

    Use QProcess to run gunzip.

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: how to unzip the file in qt using gzip

    Or use KArchive http://inqlude.org/libraries/karchive.html

    Cheers,
    _

  4. The following user says thank you to anda_skoa for this useful post:

    iswaryasenthilkumar (23rd March 2015)

  5. #4
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to unzip the file in qt using gzip

    can you give some examples plss.
    Quote Originally Posted by jthomps View Post
    Use QProcess to run gunzip.
    i have to unzip the files using gzip..
    Quote Originally Posted by anda_skoa View Post

  6. #5
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: how to unzip the file in qt using gzip

    Quote Originally Posted by iswaryasenthilkumar View Post
    can you give some examples plss.
    Not until you have read the docs for QProcess and attempted to implement.

  7. #6
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to unzip the file in qt using gzip

    i read and implemented in my code bt i dont get any result from my code
    Quote Originally Posted by jthomps View Post
    Not until you have read the docs for QProcess and attempted to implement.

  8. #7
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: how to unzip the file in qt using gzip

    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.

  9. #8
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to unzip the file in qt using gzip

    this was my code
    Qt Code:
    1. #include "widget.h"
    2. #include "ui_widget.h"
    3. #include<QtGui>
    4.  
    5. Widget::Widget(QWidget *parent) :
    6. QWidget(parent),
    7. ui(new Ui::Widget)
    8. {
    9.  
    10. QString program = "/home/digital_images/Desktop/zipfile.zip.gz";//path to zip file
    11. QStringList arguments;
    12. myProcess = new QProcess(this);
    13. connect (myProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(printOut()));
    14. connect (myProcess, SIGNAL(readyReadStandardError()), this, SLOT(printError()));
    15. myProcess->start(program, arguments);
    16. myProcess->waitForFinished();
    17. ui->setupUi(this);
    18. }
    19.  
    20. Widget::~Widget()
    21. {
    22. delete ui;
    23. }
    24. void Widget::printOut()
    25. {
    26. QByteArray byteArray = myProcess->readAllStandardOutput();
    27. QStringList strLines = QString(byteArray).split("\n");
    28.  
    29. foreach (QString line, strLines)
    30. {
    31. qDebug()<<line<<"Outputline";
    32. }
    33.  
    34. }
    35. void Widget::printError()
    36. {
    37. QByteArray byteArray = myProcess->readAllStandardError();
    38. QStringList strLines = QString(byteArray).split("\n");
    39.  
    40. foreach (QString line, strLines)
    41. {
    42. qDebug()<<"Errorline"<<line;
    43. }
    44. }
    To copy to clipboard, switch view to plain text mode 
    what am doing wrong please guide me
    Quote Originally Posted by jthomps View Post
    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.

  10. #9
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: how to unzip the file in qt using gzip

    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 06:29.

  11. The following user says thank you to jefftee for this useful post:

    iswaryasenthilkumar (24th March 2015)

  12. #10
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to unzip the file in qt using gzip

    QString program = " " //this should contain path of the program??
    QStringList arguments;
    arguments=" " // this should contain path of the zip file??


    Added after 5 minutes:


    Qt Code:
    1. QString program = "./path/to/Qt/examples/widgets/analogclock";
    2. QStringList arguments;
    3. arguments << "-style" << "motif";
    4.  
    5. QProcess *myProcess = new QProcess(parent);
    6. myProcess->start(program, arguments);
    To copy to clipboard, switch view to plain text mode 
    i have doubt in above i mentioned code.. what is meaning for this line arguments << "-style" << "motif";
    waht ia have to mention in QString program = "./path/to/Qt/examples/widgets/analogclock";
    Last edited by iswaryasenthilkumar; 24th March 2015 at 06:34.

  13. #11
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: how to unzip the file in qt using gzip

    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:

    Qt Code:
    1. /usr/bin/gunzip /some/path/to/your/zip/file
    To copy to clipboard, switch view to plain text mode 
    You might want to pass other arguments to gunzip like:
    Qt Code:
    1. /usr/bin/gunzip -v /some/path/to/your/zip/file
    To 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.

    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.

  14. The following user says thank you to jefftee for this useful post:

    iswaryasenthilkumar (24th March 2015)

  15. #12
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to unzip the file in qt using gzip

    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

  16. #13
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: how to unzip the file in qt using gzip

    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.

  17. The following user says thank you to jefftee for this useful post:

    iswaryasenthilkumar (24th March 2015)

  18. #14
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to unzip the file in qt using gzip

    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

  19. #15
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: how to unzip the file in qt using gzip

    Quote Originally Posted by Radek View Post
    If you have KDE, the better solution is using KZip and KArchiveEntry objects from libkdecore. libkdecore manual is at api.kde.org
    KArchive is available as a stand-alone library.
    It is a so-called Tier 1 Framework of KDE Frameworks, i.e. one without any other dependencies than Qt itself.

    Cheers,
    _

  20. #16
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to unzip the file in qt using gzip

    Or try this library

  21. #17
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to unzip the file in qt using gzip

    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.

  22. #18
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to unzip the file in qt using gzip

    gzip was installed in my linux bt i couldn't find out were it was placed

  23. #19
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: how to unzip the file in qt using gzip

    Quote Originally Posted by Radek View Post
    AFAIK, libkarchive wasn't released as a stand-alone library.
    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,
    _

  24. #20
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to unzip the file in qt using gzip

    i wriiten code
    Qt Code:
    1. QString program="/home/digital_images/todaytomrowcheck";//this was my qt program path
    2. QStringList arguments;
    3. arguments<<" /home/digital_images/Desktop/zipfile.zip.gz"; // this was my zipfile path
    4. myProcess=new QProcess(this);
    5. myProcess->start(program,arguments);
    6. QByteArray result=myProcess->readAll();
    7. qDebug()<<result;
    To copy to clipboard, switch view to plain text mode 
    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 implement
    Thanks in advance

Similar Threads

  1. unzip zip file contains files and folders with quazip
    By nhocjerry in forum Qt Programming
    Replies: 1
    Last Post: 7th November 2013, 09:19
  2. Need simple example with OSDaB-Zip unzip file
    By noborder in forum Newbie
    Replies: 2
    Last Post: 17th January 2013, 22:59
  3. unZip via 7z.
    By noborder in forum Newbie
    Replies: 9
    Last Post: 23rd December 2012, 20:26
  4. How to Zip/Unzip with QT for symbian???
    By baka3k in forum Newbie
    Replies: 2
    Last Post: 22nd June 2011, 09:24
  5. OpenOffice file to QTextEdit (Unzip Problem)
    By patrik08 in forum Qt Programming
    Replies: 6
    Last Post: 27th November 2006, 11:32

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.