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

Ziller Eike Eike.Ziller at digia.com
Wed Jun 19 11:30:12 CEST 2013


On 19.06.2013, at 09:47, Joerg Bornemann <joerg.bornemann at digia.com> wrote:

> 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
> 
>> 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.

or as suggested by Lorenz QString::fromLatin1(…).arg(…) for non-translatable strings for which you want to use arg()

> BR,
> 
> Joerg
> 
> P.S. It's possible to remove that define from your plugin but that's 
> considered bad style.
> 
> -- 
> Joerg Bornemann
> Digia, Qt
> http://qt.digia.com/
> 
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qt-creator

-- 
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