Questions tagged [qchar]

The QChar class, part of the Qt framework, provides a 16-bit Unicode character.

In Qt, Unicode characters are 16-bit entities without any markup or structure. This class represents such an entity. It is lightweight, so it can be used everywhere. Most compilers treat it like a unsigned short.

23 questions
13
votes
1 answer

Qt: Get ASCII Code From QChar

I need to get the ASCII code from a QChar. In Qt 5.2 QChar::ToAscii has been removed. Here is my code. How can I get the ASCII code? QString data; int key; key = data.at(i);
Mo3in
  • 369
  • 1
  • 7
  • 19
11
votes
4 answers

How can non-ASCII characters be detected in a QString?

I want to detect if the user has inputted a non-ASCII (otherwise incorrectly known as Unicode) character (for example, り) in a file save dialog box. As I am using Qt, any non-ASCII characters are properly saved in a QString, but I can't figure out…
Roderick
  • 2,383
  • 3
  • 20
  • 33
9
votes
1 answer

How to cast a QChar to int

In C++ there is a way to cast a char to int and get the ascii value in return. Is there such a way to do the same with a qchar? Since unicode supports so many characters and some of them are actually looking alike, it is sometimes hard to tell what…
alexander remus
  • 409
  • 1
  • 4
  • 11
7
votes
3 answers

Retrieve Unicode code points > U+FFFF from QChar

I have an application that is supposed to deal with all kinds of characters and at some point display information about them. I use Qt and its inherent Unicode support in QChar, QString etc. Now I need the code point of a QChar in order to look up…
Sebastian Negraszus
  • 11,915
  • 7
  • 43
  • 70
5
votes
1 answer

Convert from 'QChar' to 'wchar_t'

I need to pass a QChar to a function that expects a wchar_t: void myFunc(wchar_t wch); Trying to just pass the QChar fails with an error: error: C2664: 'myFunc' : cannot convert parameter 1 from 'QChar' to 'wchar_t'
sashoalm
  • 75,001
  • 122
  • 434
  • 781
3
votes
2 answers

How can I determine the Unicode block of a character, specifically a Qt QChar?

In Java, I was able to determine if a particular character was for example, a Japanese Kanji using Unicode.blockOf(Character). I'm trying to do the same for a QChar, but couldn't find a relevant function to do this. I'm wondering if I just missed…
neuviemeporte
  • 6,310
  • 10
  • 49
  • 78
2
votes
1 answer

QChar get digit value if `isDigit()`

How to get the digits value elegantly? QChar qc('4'); int val=-1; if(qc.isDigit()){ val = qc.toLatin1() - '0'; } does not look that good. Neither does converting to QString since creating a QString object and start parsing just for this purpose…
vlad_tepesch
  • 6,681
  • 1
  • 38
  • 80
1
vote
2 answers

How can I evaluate a QChar object in a switch?

Going through a bunch of code, looking to improve it. I came across this bit: if (c == '<' || c == '>') { pattern.append("\\b"); } else if (c == 'a') { pattern.append("[a-zA-Z]"); } else if (c == 'A') { pattern.append("[^a-zA-Z]"); }…
Anon
  • 2,267
  • 3
  • 34
  • 51
1
vote
1 answer

How to convert only the next one character from a UTF-8 byte array efficiently?

I have this code which works: QString qs = QString::fromUtf8(bp,ut).at(0); QChar c(qs[0]); Where bp is a QByteArray::const_pointer, and ut is the maximum expected length of the UTF-8 encoded Unicode code-point. I then grab the first QChar c from…
Harvey
  • 2,062
  • 2
  • 21
  • 38
1
vote
4 answers

Pushing a QChar in QString

#include #include int main(int argc, char *argv[]) { QCoreApplication a (argc, argv); unsigned char VEL_LEFT = 0; VEL_LEFT = VEL_LEFT | 100; QString packet; packet.push_back (QChar (VEL_LEFT)); …
Aquarius_Girl
  • 21,790
  • 65
  • 230
  • 411
1
vote
1 answer

Generate random QString yields same result every time

I'm working on a QT project where a user inputs their full name and the program generates a random 5 character password based off of the letters in their name. Unfortunate I've run into an issue where it works but every time I rerun the program it…
Barry Michael Doyle
  • 9,333
  • 30
  • 83
  • 143
1
vote
1 answer

How can I convert QString to int for Unicodes? for QWSServer sendKeyEvent

how can I convert my QString composed of just one unicode to QChar and char? I have this character cedilla. http://graphemica.com/%C3%A7 I don't have any idea yet about QChar but I tried using this code for converting QString to char. char…
0
votes
0 answers

QString with unicode characters to QByteArray

I have a QString which contains some unicode chars, and I want to convert the QString to a QByteArray. (Which is later converted back to a QString) If I use toLatin, toUtf8 or toLocal8bit the unicode characters are lost upon conversion. How to I…
TSG
  • 4,242
  • 9
  • 61
  • 121
0
votes
0 answers

Why does QChar( Qt::Key_Right ) now segfault?

I am updating some old cold from a project known as QFakeVim, and it is taking keyboard inputs as integers, and then returning QChar's based on that integer. That is not particularly important other than the fact that this code used to be…
0
votes
1 answer

Convert multibyte character array to QChar array

I have two buffers (example sizes): char c[512]; QChar q[256]; Assuming 'c' contains multibyte character string (UTF-8). I need to convert it to QChar sequence and place it in 'q'. I guess a good example of what I need could be MultiByteToWideChar…
Pavele
  • 3
  • 2
1
2