Your "solution" is dangerous. QString::fromUcs4() requires a NUL terminated UCS4 string if the length (second) argument is not specified. You are not providing a length or a NUL here. That it does not crash is just a happy coincidence.
@
QString str = QString::fromUcs4(&ui, 1);
@