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

Joerg Bornemann joerg.bornemann at digia.com
Wed Jun 19 09:47:45 CEST 2013


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.


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/




More information about the Qt-creator mailing list