+ Reply to Thread
Results 1 to 2 of 2

Thread: converiosn of hex data char array to Qstring

  1. #1

    Question converiosn of hex data char array to Qstring

    hi users
    i am using for last one year.
    but i am having one problem.
    as per my new requirement i have to receive hex data from RS422 port and display the received hex data in any display widget.

    so i started to code.
    my code has one unsigned char array and few more widgets for other opeartions

    my code looks like thsi

    unsigned received_hexbuff[62];

    ---
    ---
    ---

    QString display_textr(received_hexbuff);
    QLabel display_lbl;
    lbl.setText(display_text);
    ---
    --
    when i compile this code it is showing in compatible QString constructor call.

    then i refer Qt docs. there i found QString constructor accpet only const char * argument type only.

    so i badly requir to convert my char array to QString which is used to display the hex data as it is.

    i request somebody to help me.
    plz.......
    thanks in advance....

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    6,482
    Thanks
    13
    Thanked 1,362 Times in 1,304 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: converiosn of hex data char array to Qstring

    I'm sure this question has been asked before but it is difficult to search for "hex" although "hexadecimal" gets hits.

    You will need to explain what you want more clearly. "Hex data char array" could mean a number of things.

    Is the data stream coming from your serial interface:
    • A series of bytes of any value that you wish to convert to a hexadecimal string. That is the interface receives 8 bytes ( 0x51 0x74 0x43 0x65 0x6e 0x74 0x72 0x65 ) and you want to display the 16 character string "517443656e747265". Look at QByteArray::toHex () and QString::QString ( const QByteArray & ba ).
    • A series of text characters that are the hexadecimal representation that you wish to convert to a binary data array. That is, the serial port receives 16 bytes ("517443656e747265") and you wish to display the 8 character string "QtCentre". Look at QByteArray::fromHex() and QString::QString ( const QByteArray & ba )
    • Something else.

+ Reply to Thread

Similar Threads

  1. Char array[6] to QString and display it
    By arunvv in forum Newbie
    Replies: 11
    Last Post: 12th March 2014, 21:48
  2. Display an image from a unsigned char array
    By Percy in forum Qt Programming
    Replies: 1
    Last Post: 1st December 2009, 21:16
  3. Converting QString to char array
    By srohit24 in forum Qt Programming
    Replies: 3
    Last Post: 22nd July 2009, 19:19
  4. Conversion Char Array to string
    By anafor2004 in forum Newbie
    Replies: 6
    Last Post: 6th May 2008, 15:35
  5. Char Array to QString
    By 3nc31 in forum Qt Programming
    Replies: 2
    Last Post: 25th November 2007, 23:18

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