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

Lorenz Haas lykurg at gmail.com
Tue Jun 18 14:07:14 CEST 2013


Hi,

for this specific one you can use QString::number() or even simpler
QVariant(m_firstRow+section+1). If you need to use arg() you can use
QString::fromLatin1("foo").arg() instead of
QString(QLatin1String("foo")).arg().

The answer to the original question is (as far as I see): yes.

Best,
Lorenz

Am 18.06.2013 13:59, schrieb Thomas Meyer:
> Hi,
> I get very often this error, if I write a plugin:
> error: C2248: 'QString::QString' : cannot access private member declared
> in class 'QString'
> 
> For example:
> ...
> returnQVariant(QString("%1").arg(m_firstRow+section+1));
> ...
> 
> I correct it with:
> ...
> returnQVariant(QString(QLatin1String("%1")).arg(m_firstRow+section+1));
> ...
> 
> So, I correct every 'QString' with 'QLatin1String'.
> Is there a better solution or is it the only one?
> 
> Thanks,
>     Thomas Meyer
> 
> 
> 
> 
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qt-creator
> 



More information about the Qt-creator mailing list