Results 1 to 12 of 12

Thread: Char array[6] to QString and display it

  1. #1
    Join Date
    Jun 2006
    Location
    San Diego, USA
    Posts
    95
    Thanks
    9
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Char array[6] to QString and display it

    How can I convert a char array[6] to QString and use it for display.

    Example:
    char array[0] = FF,
    char array[1] = FF,
    char array[2] = FF,
    char array[3] = FF,
    char array[4] = FF,
    char array[5] = FF

    Use this char array, convert it to QString.
    Help me out for such conversion.

    Thanks & Regards,
    Arun.

  2. #2
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Char array[6] to QString and display it

    Quote Originally Posted by arunvv View Post
    How can I convert a char array[6] to QString and use it for display.

    Example:
    char array[0] = FF,
    char array[1] = FF,
    char array[2] = FF,
    char array[3] = FF,
    char array[4] = FF,
    char array[5] = FF

    Use this char array, convert it to QString.
    Help me out for such conversion.

    Thanks & Regards,
    Arun.
    I am sorry but is this c++ ? Probably you mean

    Qt Code:
    1. char array[6];
    2. array[0] = 0xFF,....
    To copy to clipboard, switch view to plain text mode 

    There is constructor for QString which constructs using "C" string.(null terminated of course)
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  3. #3
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Char array[6] to QString and display it

    You can use QString::QString ( QChar ch ) and operator+=() for that. However, You are not using the correct C++ for asking problem. Which is already shown by Mr. GOPALA KRISHNA.
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  4. #4
    Join Date
    Jun 2006
    Location
    San Diego, USA
    Posts
    95
    Thanks
    9
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Char array[6] to QString and display it

    Thanks for your reply.

    I am using C++. So what function I need to use, if there is no function, how can i convert array of characters to QString.

    Thanks & Regards,
    Arun.

  5. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Char array[6] to QString and display it

    Did you try ...reading QString docs?
    J-P Nurmi

  6. #6
    Join Date
    Jun 2006
    Location
    San Diego, USA
    Posts
    95
    Thanks
    9
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Char array[6] to QString and display it

    I read QString Docs, But I don't see any thing which converts array to QString.

    Please let me know how to convert it.

    Thanks,
    Arun

  7. #7
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Char array[6] to QString and display it

    Do you know the relation between char[] and char*?
    J-P Nurmi

  8. #8
    Join Date
    Jun 2006
    Location
    San Diego, USA
    Posts
    95
    Thanks
    9
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Char array[6] to QString and display it

    Thanks to all it solved now.

  9. #9
    Join Date
    Jan 2008
    Posts
    72
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Cool Re: Char array[6] to QString and display it

    char chararray [15];
    QString theqstring ("This is a character array");

    strcpy (chararray, theqstring.latin1());

    Using this u can convert QString to char[]

  10. #10
    Join Date
    Dec 2008
    Posts
    2
    Platforms
    Unix/X11

    Default Re: Char array[6] to QString and display it

    hi i am a Qtforum user
    i am also suffering from same problem like you
    can you tell me how did you solved ur proble
    plz..
    i need to display hex data array(char type) in QLabel

    waiting for ur reply
    thanks in advance

  11. #11
    Join Date
    Mar 2014
    Posts
    1
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Post Re: Char array[6] to QString and display it

    Quote Originally Posted by arunvv View Post
    Thanks to all it solved now.
    Hi... Can you please tell me how you solved this issue ??? as i also need to do the same thing....

  12. #12
    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: Char array[6] to QString and display it

    What have you actually tried? What do you actually have as input? This thread contains a solution and some hints.

Similar Threads

  1. Display '<' as HTML in QString
    By mclark in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2007, 22:43

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.