[Qt-creator] Cannot access private member declared in class 'QString'
Ziller Eike
Eike.Ziller at digia.com
Wed Jun 19 12:21:34 CEST 2013
On 19.06.2013, at 12:02, Thomas Meyer <public at meyer-thomas.com>
wrote:
> 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.
I you build Qt Creator and your plugin with Qt 5, then you can use QStringLiteral. Qt Creator upstream still requires compatibility with Qt 4, so you should not do that if you want to upstream what you do, at least.
Br, Eike
--
Eike Ziller, Senior Software Engineer - Digia, Qt
Digia Germany GmbH, Rudower Chaussee 13, D-12489 Berlin
Geschäftsführer: Mika Pälsi, Juha Varelius, Anja Wasenius
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B
More information about the Qt-creator
mailing list