Results 1 to 4 of 4

Thread: Checking QByteArray

  1. #1
    Join Date
    Mar 2011
    Posts
    53
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Checking QByteArray

    I have one question is possible some how to check what kind of data type the QByteArray buffer is carring? I am expecting three types: QStringList, QString,, and the exact date which i will write to the file? I tried using QByteArray::contains("STORAGE"), becouse I know that if it will be QStringList, each QString in that QStringList will have "STORAGE" somewhere. But this is not actually working.When i do contains("S") it sees the single char but only one at time.

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Checking QByteArray

    QByteArray, as its name suggests, contains an array of bytes. It doesn't care about what the data is or how its formatted. It's just a sequence of raw, unformatted bytes.

    What are you actually trying to do?

  3. #3
    Join Date
    Mar 2011
    Posts
    53
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Checking QByteArray

    When client connects to the server the client firstly receives QStringList from server, then it sends many files one by one. I want to do this like this:client doesn't know what he will get, he only by checking the QByteArray he received he should know what to do.
    Last edited by camol; 18th March 2011 at 09:08.

  4. #4
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Checking QByteArray

    Right, so you need to develop a protocol which supports what you want to do.

    For example, the http protocol sends the text string "Content-length" so that clients know the amount of data to expect, and strings such as "Content-Disposition: attachment; filename='filename.ext'". So the client knows a default filename before asking the user if they wish to rename it.

    Once you had sent the data for all files, you can begin data transfer of the files. Its a good idea to use a synchronisation (expected sequence of bytes) so the client knows they have received each file correctly.

Similar Threads

  1. Checking for gui events
    By mgb in forum Qt Programming
    Replies: 8
    Last Post: 8th February 2011, 22:07
  2. Replies: 9
    Last Post: 25th July 2009, 13:27
  3. Checking if a pointer is dangling
    By Cruz in forum Qt Programming
    Replies: 8
    Last Post: 15th February 2009, 13:13
  4. Checking if bad pointer?
    By steg90 in forum Qt Programming
    Replies: 4
    Last Post: 22nd May 2007, 09:06
  5. checking for null
    By drkbkr in forum General Programming
    Replies: 6
    Last Post: 13th March 2006, 21:54

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.