Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QString convert unicode
Sorry for this but i have one question that idk because i read lot that qstring is internally unicode. But if i have different string's or char's how i can do fast the conversion to unicode Utf8??
bludger last edited by
You could use some of QString's static convert methods, like: fromLatin1();
The available methods are mentioned here: http://doc.qt.io/qt-5/qstring.html#static-public-members
Else you could use a QTextCodec which haves support for a number of character sets, take a look at: http://doc.qt.io/qt-5/qtextcodec.html
Jeronimo last edited by kshegunov
I edited your post by accident and its text was lost, I am sorry!
So i can convert in utf16 like
You're doing it wrong.
But i want to pass to unicode utf8
As I said, use QString::toUtf8:
wchar_t buffer QString string = QString::fromWCharArray(buffer); char * utf8encoded = string.toUtf8();
say me the follow:
'inicializando' : no se puede realizar la conversi¢n de 'QByteArray' a 'char *'
No hay disponible ning£n operador de conversi¢n definido por el usuario que pueda realizar esta conversi¢n, o bien no se puede llamar al operador
In other words when i do this
wchar_t buffer; QString string = QString::fromWCharArray(buffer); char *utf8encoded = string.toUtf8();
I can't do the conversion.
You really should check the docs on this.
I've made a minor mistake, but it's easily correctable.
QByteArray utf8data = string.toUtf8(); const char * utf8encoded = utf8data.constData();
QByteArray utf8data = string.toUtf8();
const char * utf8encoded = utf8data.constData();
one question normally i think must show unicode text like this :
Normally i can do this
But i have one problem with this only show me in unicode when i am using some modificator like ctrl. It's for one keyboard in different languages.
I don't understand the question. Unicode has little to do with control or with the keyboard, it's an encoding for text, not a device driver ...
@kshegunov i think is problem of my instance or i'm doing something wrong.
Then tell us what you are trying to do.
@SGaist Sorry i said instance¿? i wanted to say encoding*
That still doesn't explain what you are trying to do.
Why do you need all these conversion ?
@SGaist i'm trying to do keyboard in different languages and like i was trying to show key's in other languages like(german or others..) i couldn't because i can't get unicode text to translate it.
Something like the QtVirtualKeyboard module ?
@SGaist Nope it's for windows so i am using setwindowshookex
Why not make use of Window's virtual keyboard ?
This post is deleted!
@SGaist Anyways i'm checking virtual keyboard thx