[Interest] qRegisterMetaType<QList<QSslError> > and type flags

Stephen Kelly stephen.kelly at kdab.com
Wed Jan 2 21:04:13 CET 2013


On Wednesday, January 02, 2013 18:12:51 Jan Kundrát wrote:
> On Wednesday, 2 January 2013 17:42:53 CEST, Stephen Kelly wrote:
> > The fix is probably to include qsslsocket.h in the translation
> > unit where you
> > have that line.
> > 
> > Of course it's a bug and an odd mistake that
> > Q_DECLARE_METATYPE(QList<QSslError>) is in qsslsocket.h instead of
> > qsslerror.h.
> 
> Hi Stephen, thanks for your answer. Adding
> Q_DECLARE_METATYPE(QList<QSslError>) to my code fixed the problem as well
> (as suggested by Thiago on IRC). Looks like there will be some discussion
> on development@ about whether the assert is the right thing in there.

I think it's a better workaround to include the header.

> > Also you should just use
> > 
> >  qRegisterMetaType<QList<QSslError> >()
> > 
> > without the string.
> 
> The 4.x docs [1] uses the variant with a string. Does your suggestion apply
> to Qt 4.x (4.6+ in my case, to be specific) as well? 

Yes.

> Shall the docs be changed? 

Probably. They might also be incomplete.

> Is there any harm in using the string in Qt5?

If you use the string you are at risk of typos. There were several such typos 
and copy-pastos in the Qt codebase.

Apart from that, Marcs point about the version without the string being faster 
is probably true:

 http://qt.gitorious.org/qt/qtbase/commit/e9ecf1b420d8f0fc4393cbfdea2fe731409d83c6

Although I think it might also be necessary to introduce a guard to make sure 
you don't call qRegisterMetaType multiple times, even with the same type and 
the same string. Otherwise you might be adding duplicate entries to the 
metatype database each time.

So unless you're deliberately creating a typedef registration (and even in 
that case, be careful), omit the string and you don't have to think about it 
anymore.

Thanks,

-- 
Stephen Kelly <stephen.kelly at kdab.com> | Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
www.kdab.com || Germany +49-30-521325470 || Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-Independent Software Solutions
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130102/92e23900/attachment.sig>


More information about the Interest mailing list