[Qt-creator] Cannot access private member declared in class 'QString'

Thomas Meyer public at meyer-thomas.com
Wed Jun 19 12:02:10 CEST 2013


Hi,
thanks (to all answers)!

So, I have to type more. :-)


Am 19.06.2013 09:47, schrieb Joerg Bornemann:
> On 18/06/2013 13:59, Thomas Meyer wrote:
>
>> I get very often this error, if I write a plugin:
>> error: C2248: 'QString::QString' : cannot access private member declared
>> in class 'QString'
> This is due to the definition of QT_NO_CAST_FROM_ASCII in the qtcreator.pri.
> See:
> http://qt-project.org/doc/qt-5.0/qtcore/qstring.html#QT_NO_CAST_FROM_ASCII
I only found it in 'lldbengineguest.cpp' (and with the definition in 
qtcreator.pri it is not
necessary, I think).

>> So, I correct every 'QString' with 'QLatin1String'.
>> Is there a better solution or is it the only one?
> For non-translatable strings use QLatin1String("...").
> Use tr("...") for translatable strings.
>
>
> BR,
>
> Joerg
>
> P.S. It's possible to remove that define from your plugin but that's
> considered bad style.
>

Meanwhile I found this:
http://www.macieira.org/blog/2011/07/qstring-improved/
and I think I can use QStringLiteral too.

Thanks,
Thomas

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-creator/attachments/20130619/8f0ad1f8/attachment.html 


More information about the Qt-creator mailing list