[Qt-interest] Weird compiler error with QString(QChar(value))
Constantin Makshin
cmakshin at gmail.com
Wed May 5 21:28:42 CEST 2010
Looks like a compiler bug to me.
This isn't directly related to your question, but QString::toUtf8() returns a QByteArray object, not a reference.
Also I suggest you to change the code to something like this:
QChar c(func_that_returns_a_unicode_value());
QString s(c);
const QByteArray utf8 = s.toUtf8();
In this variant there's no may-be-the-cause construction "QString s(QChar(...))" and if you need the original Unicode value, you can it by using QChar functions.
On Wed, 05 May 2010 22:51:00 +0400, Nikos Chantziaras <realnc at arcor.de> wrote:
> Not sure I understand why this won't compile:
>
> int unicodeValue = func_that_returns_a_unicode_value();
> QString s(QChar(unicodeValue));
> const QByteArray& utf8 = s.toUtf8(); // <-- error happens here
>
> I get:
>
> error: request for member 'toUtf8' in 's', which is of non-class type
> 'QString(QChar)'
>
> I'm confused as hell :P
--
Constantin Makshin
More information about the Qt-interest-old
mailing list