Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. qUncompress Z_DATA_ERROR error

qUncompress Z_DATA_ERROR error

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Julieng
    wrote on last edited by Julieng
    #1

    Hello,

    I am facing an issue which I cannot solve when I uncompress data with qUncompress. I need to open an XML file to be read by a QDomDocument.

    When tesing this, it works perfectly.

                QFile f1(filePath);
                f1.open(QIODevice::ReadOnly | QIODevice::Text);
                QByteArray b1 = f1.readAll();
                QByteArray b2 = qCompress(b1);
                QByteArray b3 = qUncompress(b2);
                document.setContent(b3);
    

    When doing the same through a QFile, it fails with error "qUncompress: Z_DATA_ERROR: Input data is corrupted"

                QFile f1(filePath);
                f1.open(QIODevice::ReadOnly | QIODevice::Text);
                QByteArray b1 = f1.readAll();
                QByteArray b2 = qCompress(b1);
    
                QFile f2(filePath + "c");
                f2.open(QIODevice::WriteOnly | QIODevice::Text);
                f2.write(b2);
    
                QFile f3(filePath + "c");
                f3.open(QIODevice::ReadOnly | QIODevice::Text);
                QByteArray b3 = qUncompress(f3.readAll());
                document.setContent(b3);
    

    I really do not understand the difference in terms of compression/decompression. Any idea ? Thanks !!

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Julieng
      wrote on last edited by
      #2

      Sorry for this post, I found my mistake : remove "QIODevice::Text" in file open arguments...

      1 Reply Last reply
      3

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved