Results 1 to 4 of 4

Thread: Store data in bits & Bytes

  1. #1
    Join Date
    Jun 2013
    Posts
    46
    Thanks
    24
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Question Store data in bits & Bytes

    Good Day,

    I have a text file that needs to be read into the program, must be modified
    & then when the data is stored again it needs to be stored in a new certain format

    Example
    Field Name | Size
    A | 2 bytes
    B | 4 bytes
    C | 12 bits
    D | 1 byte
    & so on...

    When I read data into program its stored in various arrays
    of type QPoint, QList<int>, QList<double> and so on

    I just need to know
    Does Qt support what I need to store data accordingly
    & if so,
    How would I go about it


    Kind Regards

    Help much appreciated
    Example will be glady accepted

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,531
    Thanks
    13
    Thanked 1,576 Times in 1,505 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Store data in bits & Bytes

    How do you intend to save a 12-bit field in a file of whole bytes? You can write any bytes you want to a QFile but nothing here has anything specifically to do with Qt.

  3. The following user says thank you to ChrisW67 for this useful post:

    2lights (9th September 2013)

  4. #3
    Join Date
    Jun 2013
    Posts
    46
    Thanks
    24
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Default Re: Store data in bits & Bytes

    Was reading up on "Serializing Qt Data Types"
    http://harmattan-dev.nokia.com/docs/...eamformat.html

    I understand the concepts just not sure how to go about storing data in relevant variable size?

    My project from among other things is to store data in defined field size
    Using a qt interface to interact with use manipulate data
    and then store data accordingly

    how does qt store its data when variables are written to a file?
    How do I control the size of the fields within this field?

    Also How do I write qt data variables to file in BINARY FORMAT

    please help

    12bits binary format How

    Please direct me in the right direction
    Last edited by 2lights; 9th September 2013 at 12:44. Reason: updated contents

  5. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,325
    Thanks
    36
    Thanked 1,527 Times in 1,478 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Store data in bits & Bytes

    QFile is a QIODevice subclass. QIODevice has low level read and write methods that write byte arrays (C style char* or Qt/C++ QByteArray).

    This has nothing to do with QDataStream, that class is for serializing data types in a Qt specific format. Your data format is different so you obviously need to write the "parsing" and "formatting" code into bytes yourself.

    Cheers,
    _

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

    2lights (9th September 2013)

Similar Threads

  1. Replies: 4
    Last Post: 23rd October 2012, 08:40
  2. How to store data in a tablemodel
    By rubikon in forum Newbie
    Replies: 11
    Last Post: 13th August 2012, 14:18
  3. Replies: 7
    Last Post: 12th September 2011, 10:52
  4. Need ideas on how to store data in SQL-Database
    By homerun4711 in forum Newbie
    Replies: 3
    Last Post: 5th January 2011, 23:10
  5. can't set serial port data bits
    By yyiu002 in forum Qt Programming
    Replies: 6
    Last Post: 23rd June 2010, 22:28

Tags for this Thread

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.