Results 1 to 4 of 4

Thread: Converting QString to char array

  1. #1
    Join Date
    Feb 2009
    Posts
    143
    Thanks
    8

    Default Converting QString to char array

    Hi

    I am using a function that accepts only charcters.

    I am using a QString variable to collect all data.

    What i need now is that to convert this QString to char array if possible.
    Whenever i try to send the QString, i get a error saying

    error: cannot convert `QCharRef' to `char' in argument passing

    what should i do to convert the QString to a char array??

  2. #2
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Converting QString to char array

    Qt Code:
    1. const char *str;
    2. QString path;
    3. ba = path.toLatin1();
    4. str = ba.data();
    5. printf("the string path will be:%s\n", str);
    To copy to clipboard, switch view to plain text mode 
    "Behind every great fortune lies a crime" - Balzac

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Converting QString to char array


  4. #4
    Join Date
    Feb 2009
    Posts
    143
    Thanks
    8

    Default Re: Converting QString to char array

    thanks for helping me out.

Similar Threads

  1. Char array[6] to QString and display it
    By arunvv in forum Newbie
    Replies: 11
    Last Post: 12th March 2014, 20:48
  2. Char Array to QString
    By 3nc31 in forum Qt Programming
    Replies: 2
    Last Post: 25th November 2007, 22:18
  3. QString to unsigned char *
    By darksaga in forum Qt Programming
    Replies: 9
    Last Post: 23rd July 2007, 07:52
  4. Problem in converting QString to QChar array?
    By KaKa in forum Qt Programming
    Replies: 2
    Last Post: 19th March 2007, 00:38
  5. Convert from iso-8859-1 to... Something else :-)
    By Nyphel in forum Qt Programming
    Replies: 4
    Last Post: 7th March 2007, 17:59

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.