[Development] QLatin1Constant and QtContacts / QtOrganizer
mathias at openismus.com
Mon Dec 19 23:08:11 CET 2011
Am Montag, den 19.12.2011, 19:18 +0000 schrieb lars.knoll at nokia.com:
> On 12/14/11 11:01 AM, "ext Todd.Rose at nokia.com" <Todd.Rose at nokia.com>
> >I'm in the early stages of trying to port a Qt4.7 app that uses
> >qt-mobility to Qt5. Today I noticed compile errors caused by the
> >duplication of qlatin1constant.h in both of these
> > modules.
> >The problem shows when you write an app that uses both the QtContacts and
> >the QtOrganizer modules. Headers within the QtContacts module will
> >sometimes include the QtOrganizer version of qlatin1constant.h (or
> >vice-versa depending on the app's include path
> > ordering). The use of namespaces in these headers is what leads to the
> >There's several solutions, and I guess it'd be best if the
> >QLatin1Constant functionality was moved to a core library, but until then
> >can we at least have the headers *within* the Contacts and Organizer
> >modules include qlatin1constant.h in an unambiguous manner?
> I'm actually wondering whether this class still makes sense in Qt 5. We've
> done some changes to QLatin1String to make it more suitable and have
> QStringLiteral in addition. That should make the need for this class
> mostly go away IMO.
+1 - QLatin1String is painful to use: You cannot really store references
to it, you constantly get trouble from C++ not being able to resolve
which of its cast operators shall be used (QString vs. QLatin1String).
Also I never really got is purpose: To enable comparison and hashing of
QtContact's string keys, and to make sure those strings don't waste
memory on heap, it would have been sufficient to use QString::
fromRawData() to initialize those constants.
Mathias Hasselmann <mathias at openismus.com>
More information about the Development