Results 1 to 4 of 4

Thread: Write each receiving QByteArray to end of a file

  1. #1
    Join Date
    Nov 2015
    Posts
    128
    Thanks
    70
    Qt products
    Qt5
    Platforms
    Windows

    Default Write each receiving QByteArray to end of a file

    Hi, I have a serial connection that I put each coming data into a QByteArray:


    Qt Code:
    1. connect(&SerialPort, SIGNAL(readyRead()), this, SLOT(slot_reading()));
    To copy to clipboard, switch view to plain text mode 


    Qt Code:
    1. //the slot:
    2. void Cserial::slot_reading()
    3. {
    4. QByteArray DataReading = SerialPort.readAll();
    5. }
    To copy to clipboard, switch view to plain text mode 

    I need to save all coming data into a file. So i must gather each QByteArray::DataReading and at the end, saving all of them into a file (by pushing a QPushButtom in name of "save").
    1-How could I gather all data?
    and then
    2-how can I save into a file?

    Thanks a lot for any help

  2. #2
    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: Write each receiving QByteArray to end of a file

    Is the button triggered file creation a "must have"?
    Otherwise you could just write the incoming data directly into a file, appending each time.

    Cheers,
    _

  3. #3
    Join Date
    Nov 2015
    Posts
    128
    Thanks
    70
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Write each receiving QByteArray to end of a file

    Quote Originally Posted by anda_skoa View Post
    Is the button triggered file creation a "must have"?
    Thanks for replying. Yes a pushButton must be.

    Quote Originally Posted by anda_skoa View Post
    write the incoming data directly into a file, appending each time.
    Working with a file makes process speed of the project too low.

  4. #4
    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: Write each receiving QByteArray to end of a file

    Ok, then create a QBuffer and write the incoming data into that.

    Get the buffer's content on button click.

    Cheers,
    _

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

    Alex22 (12th November 2016)

Similar Threads

  1. Replies: 4
    Last Post: 25th December 2014, 09:09
  2. Replies: 2
    Last Post: 13th January 2014, 07:27
  3. Replies: 2
    Last Post: 8th August 2012, 11:11
  4. Replies: 2
    Last Post: 2nd November 2010, 05:15
  5. Problems mapping an image file into QByteArray
    By Dark_Tower in forum Qt Programming
    Replies: 3
    Last Post: 12th December 2006, 21:23

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.