Results 1 to 4 of 4

Thread: conversion from QString to const uint8 *

  1. #1
    Join Date
    Dec 2006
    Posts
    211
    Thanks
    27
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question conversion from QString to const uint8 *

    Hi All,

    I m using Qt 4.2.2 on my Intel Mac.
    I want to convert QString to const uint8 *.

    In Qt3 I m using
    (const UInt8*)cCompletePath.utf8()

    to convert this.

    But how to do this in Qt 4.2.2 ?

    I m using

    (const UInt8*)cCompletePath.utf16()

    to Do this but this is converting into 16 bit unicode but I need it in 8 bit unicode.


    If anyone knows then plz help me.

    Thanks.

  2. #2
    Join Date
    Jan 2006
    Posts
    128
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: conversion from QString to const uint8 *

    Take a look at the wonderfull documentation.

    Coding is left as an exercise for the reader ;-)

  3. The following user says thank you to camel for this useful post:

    vishal.chauhan (20th February 2007)

  4. #3
    Join Date
    Dec 2006
    Posts
    211
    Thanks
    27
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question Re: conversion from QString to const uint8 *

    Thanks for reply.

    I have tried convert the QString to the unicode using toUft8
    but the value return by this is a ByteArray and how I convert this value into (const UInt8*).

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: conversion from QString to const uint8 *

    Use the constData() method from QByteArray. Just remember to copy the buffer if you want to store it anywhere as the pointer will be valid only as long as the byte array object is valid.

  6. The following user says thank you to wysota for this useful post:

    vishal.chauhan (20th February 2007)

Similar Threads

  1. No QCalendarWidget in designer? 4.2.0-tp1
    By Spockmeat in forum Qt Tools
    Replies: 2
    Last Post: 9th August 2006, 18:13
  2. QTableView paints too much
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 26th July 2006, 18:42
  3. Delegates and Table
    By ankurjain in forum Qt Programming
    Replies: 8
    Last Post: 18th May 2006, 19:47
  4. Replies: 4
    Last Post: 24th March 2006, 22:50
  5. Problem with custom widget
    By jnana in forum Qt Programming
    Replies: 3
    Last Post: 15th March 2006, 11:55

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.