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. [SOLVED] How to get text of svgz file?

[SOLVED] How to get text of svgz file?

Scheduled Pinned Locked Moved General and Desktop
10 Posts 4 Posters 6.3k 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.
  • R Offline
    R Offline
    RazrFalcon
    wrote on 31 Oct 2011, 21:06 last edited by
    #1

    I need to add svgz(zipped svg) content to the QDomDocument.
    Usual svg i can open with QFile & QTextStream.

    Only way I find, is to extract it with gunzip. But then I must to use additional qprocess.

    Is there any other way?

    1 Reply Last reply
    0
    • P Offline
      P Offline
      p-himik
      wrote on 1 Nov 2011, 02:31 last edited by
      #2

      You can use QuaZIP. It's a wrapper for zlib.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on 1 Nov 2011, 07:25 last edited by
        #3

        There is a FAQ entry on compression and decompression.

        1 Reply Last reply
        0
        • R Offline
          R Offline
          RazrFalcon
          wrote on 1 Nov 2011, 11:54 last edited by
          #4

          I can't uncompress svgz with quazip or qzipreader.
          I can uncompress only usual zip files.

          Only way I find, is to rename svgz to gz.
          And then:
          @gunzip vector.gz@
          :(

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on 1 Nov 2011, 12:20 last edited by
            #5

            You can start a QProcess using "gunzip -c", then feed the compressed svgz to the process' stdin (using QProcess::write!) and read the decompressed data from the process' stdout (using QProcess::read!). As QProcess is a QIODevice, you might try to attach a QTextStream to it for reading.

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0
            • R Offline
              R Offline
              RazrFalcon
              wrote on 1 Nov 2011, 13:03 last edited by
              #6

              :)
              So, Qt can't read svgz.
              I'll try to use method proposed by Volker.
              Thanks.

              1 Reply Last reply
              0
              • R Offline
                R Offline
                RazrFalcon
                wrote on 1 Nov 2011, 13:20 last edited by
                #7

                It was easier than I thought:
                @QProcess proc(this);
                QStringList args;
                args<<"-c"<<"../vector.svgz";
                proc.start("gunzip",args);
                proc.waitForFinished();
                qDebug()<<proc.readAll();@
                At the output I get svg text.
                Then I replace qDebug with it:
                @QDomDocument dom;
                dom.setContent(proc.readAll());@
                And my problem is solved!
                Thanks Volker again.

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goetz
                  wrote on 1 Nov 2011, 17:18 last edited by
                  #8

                  You're welcome. You might try

                  @
                  QDomDocument dom;
                  dom.setContent(&proc);
                  @

                  Maybe that saves you from copying around some bytes in the QByteArray.

                  http://www.catb.org/~esr/faqs/smart-questions.html

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    RazrFalcon
                    wrote on 1 Nov 2011, 17:57 last edited by
                    #9

                    Thanks a lot. Again. :)
                    I didn't know about this method.

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      goetz
                      wrote on 1 Nov 2011, 18:16 last edited by
                      #10

                      In Qt, many classes that deal with data have a constructor or method that uses a QIODevice pointer as data source. It's always worth a try to look for those.

                      http://www.catb.org/~esr/faqs/smart-questions.html

                      1 Reply Last reply
                      0

                      3/10

                      1 Nov 2011, 07:25

                      topic:navigator.unread, 7
                      • Login

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