Results 1 to 10 of 10

Thread: QString to unsigned char *

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2007
    Posts
    8
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QString to unsigned char *

    try the following un-tested code;

    QString str ="ABCDEFGHIJK";
    unsigned char* uca;

    uca = new unsigned char[str.length()];
    for(int i=0; i<str.length(); i++) uca[i] = str.substr(i,1);

    cout<<uca<<endl;

    delete [] uca;

    comlink21

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 541 Times in 521 Posts

    Default Re: QString to unsigned char *

    Quote Originally Posted by comlink21 View Post
    try the following un-tested code;

    QString str ="ABCDEFGHIJK";
    unsigned char* uca;

    uca = new unsigned char[str.length()];
    for(int i=0; i<str.length(); i++) uca[i] = str.substr(i,1);

    cout<<uca<<endl;

    delete [] uca;

    comlink21
    What is your point?

Similar Threads

  1. Convert from iso-8859-1 to... Something else :-)
    By Nyphel in forum Qt Programming
    Replies: 4
    Last Post: 7th March 2007, 18:59
  2. QString to Char
    By kenny_isles in forum Newbie
    Replies: 1
    Last Post: 23rd February 2007, 10:51
  3. QString to const char
    By TheRonin in forum Newbie
    Replies: 2
    Last Post: 12th February 2007, 15:43
  4. unable to save QCStrings properly in a buffer
    By nass in forum Qt Programming
    Replies: 13
    Last Post: 15th November 2006, 21:49
  5. QString to char
    By boss_bhat in forum Qt Programming
    Replies: 7
    Last Post: 21st July 2006, 00:26

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.