Results 1 to 2 of 2

Thread: Problem in storing hex data to char variable

  1. #1
    Join Date
    Feb 2014
    Posts
    31
    Thanks
    7
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Post Problem in storing hex data to char variable

    Hi to all,
    I am new to Qt, i am writing code to convert integer to hex value and to store it in a char variable. I am converting int to hex value, but am facing problem in storing the resultant value to a char variable.

    My code is..

    int id=20;
    QString sid=QString::number(id,16);
    But I want to store the hex value to char variable not QString or char* or char array...
    Please help me..
    Thanks in advance..

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

    Default Re: Problem in storing hex data to char variable

    You can't in general. Any value greater than 15 you give QString::number() will convert to two or more characters. Obviously that cannot fit in a single char variable.

Similar Threads

  1. Data Reading and Storing in arrays
    By kango in forum Newbie
    Replies: 8
    Last Post: 6th January 2013, 15:13
  2. Replies: 0
    Last Post: 4th October 2011, 06:52
  3. Saving and storing data,QtSql
    By salmanmanekia in forum Newbie
    Replies: 7
    Last Post: 20th April 2010, 19:08
  4. storing data in hexadecimal format
    By aj2903 in forum Qt Programming
    Replies: 6
    Last Post: 13th January 2010, 05:29
  5. Replies: 1
    Last Post: 3rd December 2009, 09:20

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.