Results 1 to 2 of 2

Thread: Convert from "mystring" to QString;

  1. #1
    Join Date
    Apr 2014
    Posts
    125
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Android Maemo/MeeGo

    Question Convert from "mystring" to QString;

    Hello;

    What is the best way (more portable - Linux and Windows, support for different character settings) to convert from either "mystring" or char* to QString?

    I'm confused between:

    QString fromAscii ( const char * str, int size = -1 )
    QString fromLatin1 ( const char * str, int size = -1 )
    QString fromLocal8Bit ( const char * str, int size = -1 )
    QString fromRawData ( const QChar * unicode, int size )
    QString fromStdString ( const std::string & str )

    Thanks,

    Mut

  2. #2
    Join Date
    Oct 2012
    Posts
    132
    Thanks
    10
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Convert from "mystring" to QString;

    It depends on the encoding of your C-style string because QString internally uses UTF-16 and thus needs to convert your string to UTF-16.
    Last edited by Infinity; 14th June 2014 at 01:41.

Similar Threads

  1. Replies: 2
    Last Post: 24th December 2015, 13:33
  2. Replies: 3
    Last Post: 27th December 2013, 18:04
  3. Replies: 5
    Last Post: 9th August 2011, 12:18
  4. qstring k="100.1",how to convert to int = 100 ?
    By lanmanck in forum Qt Programming
    Replies: 4
    Last Post: 9th September 2009, 04:15
  5. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05

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.