KDE/kdelibs/kdeui
Aaron J. Seigo
aseigo at kde.org
Sun Sep 14 23:05:38 BST 2008
On Sunday 14 September 2008, Ingo Klöcker wrote:
> On Sunday 14 September 2008, Michael Pyne wrote:
> > On Sunday 14 September 2008, Albert Astals Cid wrote:
> > > const QList<QAction*> KActionCategory::actions() const
> > >
> > > seems not really KDE style to me, afair we do
> > >
> > > QList<QAction*> KActionCategory::actions() const
> > >
> > > but Michael says he copied it from KActionCollection, can someone
> > > show any light?
> >
> > From the API docs both styles are used in KActionCollection (look at
> > actionGroups() and actions()).
> >
> > As far as which is correct I think it depends on what exactly they're
> > trying to accomplish. If the idea of const QList<QAction *> is to
> > force any pointers retrieved through the QList to be const QAction *
> > then it makes sense I think.
>
> Unfortunately, this idea doesn't work because of
> T QList<T>::value( int i ) const
> i.e. QList<QAction *>::value( int i ) does not return a const QAction *,
> but a QAction *. All other const methods of QList<T> return a const T
> &, though.
it's also really annoying when what you're wanting to do is retrieve a list,
add to that list and then do something with that list.
when the return is const, you can't do so easily. when the return is non-
const, Qt will make a copy of the list and let you proceed on as usual.
so it's a lot more convenient for usage without the const; and since as you
note the const qualifier doesn't *really* protect the pointers anyways ..
what's the point? =)
i ran into this just the other day in the KTimezone* classes.
--
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA EE75 D6B7 2EB1 A7F1 DB43
KDE core developer sponsored by Trolltech
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20080914/c169ee99/attachment.sig>
More information about the kde-core-devel
mailing list