Results 1 to 3 of 3

Thread: QByteArray can not support unsigned char?

  1. #1
    Join Date
    Apr 2009
    Location
    Gdansk, Poland
    Posts
    11
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QByteArray can not support unsigned char?

    I want read binary file and load data to unsigned char array. My code is:
    Qt Code:
    1. QFile f("a.a");
    2. f.open(QFile::ReadOnly);
    3. QByteArray d = f.readAll();
    4. f.close();
    To copy to clipboard, switch view to plain text mode 
    Functions from QFile and QByteArray support only signed char not unsigned char. I can not understand reason for using signed char because for me byte=unsigned char.
    Is there any possibility to read unsigned char from file? Of course I can convert every signed char to unsigned char but mayby exsist easier way for this problem?
    Last edited by olosie; 4th March 2010 at 12:22.

  2. #2
    Join Date
    Apr 2009
    Location
    Gdansk, Poland
    Posts
    11
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QByteArray can not support unsigned char?

    Nobody knows solution?

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

    Default Re: QByteArray can not support unsigned char?

    QByteArray doesn't specify either signed or unsigned, check the header file. Therefore you can define it as either signed or unsigned depending on your requirements.

    This is not a Qt issue, it's covered in the introduction to GCC.

Similar Threads

  1. Creating a pixmap from unsigned char*
    By winder in forum Qt Programming
    Replies: 9
    Last Post: 6th July 2021, 13:56
  2. convert from unsigned char* to QString
    By bhaskar in forum Qt Programming
    Replies: 2
    Last Post: 12th February 2010, 06:36
  3. unsigned char * to QString
    By elina.du in forum Qt Programming
    Replies: 2
    Last Post: 25th March 2009, 08:33
  4. Conversion from unsigned char* to unsigned char
    By santosh.kumar in forum General Programming
    Replies: 1
    Last Post: 6th August 2007, 13:12
  5. QString to unsigned char *
    By darksaga in forum Qt Programming
    Replies: 9
    Last Post: 23rd July 2007, 07:52

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
  •  
Qt is a trademark of The Qt Company.