Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

QDataStream: Open QString Values in gedit

qdatastream qstring value gedit qt stream

This topic has been archived. This means that you cannot reply to this topic.
6 replies to this topic

#1 untitled_1

untitled_1

    CC Addict

  • Validating
  • PipPipPipPipPip
  • 129 posts

Posted 16 February 2013 - 01:24 AM

Hi all

 

I have made a class that inherits from QDataStream, it works perfectly well...but the problem i have is that i cant open it using gedit, i have done some research into it and it seems that by default QDataStream stores QString values in binary format in such a way as to enable easy transmission over the network and QDataStream also seems to add some extra information when writing to file. Does anyone have any suggestions as to how i can make it store it in such a way that i can open it with qedit. I have tried to convert the QString values that i am trying to write to file to ascii, but qedit still cant open it. Do u guys think it is impossible to store a file in human readable form?

 

thanks in advance


Edited by Roger, 21 February 2013 - 08:04 AM.


#2 untitled_1

untitled_1

    CC Addict

  • Validating
  • PipPipPipPipPip
  • 129 posts

Posted 18 February 2013 - 04:43 AM

Well, it seems there is no other way  to be able to open a file generated by QDataStream except for writting a small app( in Qt ) to open and read the file, i have searched the internet high and low and found no solution with regards to functions that can do this, i think it is pretty lame that there is no functions that can specify that QDataStream should save a file as a plain text file that can be opened by gedit( or whatever other text editors ).



#3 Flying Dutchman

Flying Dutchman

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1090 posts

Posted 18 February 2013 - 01:16 PM

The QDataStream class provides serialization of binary data to a QIODevice.

 

A data stream is a binary stream of encoded information which is 100% independent of the host computer's operating system, CPU or byte order. For example, a data stream that is written by a PC under Windows can be read by a Sun SPARC running Solaris.

You can also use a data stream to read/write raw unencoded binary data. If you want a "parsing" input stream, see QTextStream.

 

 

Taken from qt-project.org


The roots of education are bitter, but the fruit is sweet.


#4 untitled_1

untitled_1

    CC Addict

  • Validating
  • PipPipPipPipPip
  • 129 posts

Posted 18 February 2013 - 09:59 PM

Thanks, i will do further research into QTextStream to see if it has the same( or at least most of ) functionality as QDataStream, since my inherting class needs specific functions from QDataStream.

 

Thanks for the refrence



#5 untitled_1

untitled_1

    CC Addict

  • Validating
  • PipPipPipPipPip
  • 129 posts

Posted 20 February 2013 - 11:02 PM

Hey all

 

Just to update you about my problem, i decided that the best option was to use QDomDocument to create human readable file using xml, i think this is the best solution.

 

Just thought i would share this with everyone  :-P



#6 Flying Dutchman

Flying Dutchman

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1090 posts

Posted 21 February 2013 - 07:12 AM

Just be careful when using XML.


The roots of education are bitter, but the fruit is sweet.


#7 untitled_1

untitled_1

    CC Addict

  • Validating
  • PipPipPipPipPip
  • 129 posts

Posted 21 February 2013 - 11:25 PM

thanks i will, i know it is a little bit of a brute force way to do things but i think it is the only way for now. I will come back to the problem and figure out if there is another way when my program is finished






Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download