Search code examples
c++qtqchar

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'

Solution

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

    wchar_t wch = qch.unicode();