5

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

1 Answers1

5

Found the answer even while I was asking the question, I needed to use QChar::unicode().

wchar_t wch = qch.unicode();
sashoalm
  • 75,001
  • 122
  • 434
  • 781
  • 1
    @egur Btw I still wasted a good 20 minutes, because it was totally unsearchable - it's declaration is `ushort unicode()`. Had it been `wchar_t toWChar()`, it would have been a non-issue. I have the habit of doing quick searches using `Ctrl+F` or just the intellisense, instead of reading every function of the class. – sashoalm Dec 13 '13 at 08:40