Michael Jansen kde at michael-jansen.biz
Mon Sep 15 17:16:42 BST 2008


> Now, even more, please note that the function:
> 	const T &QList<T>::operator[](int i) const
> when expanding with T = QAction*, expands to:
> 	QAction * const &QList<QAction *>::operator[](int i) const
> Note the position of the const: it's 'QAction * const', not 'const QAction
> *' like Ingo and Michael are thinking.

Just for the record: "I haven't thought anything. I just copied code. Which is 
much worse :-) .

Returning an QList<QAction*> means returning a copy of the list (not 
technically - implicit sharing ... - but from the perspective of the caller 
that doesn't matter). If i change the list i got, i won't change anything for 
the original list.

Has the const any kind of effect? Itcould be there to prevent the calling code 
to change the list it gets, but still allow to change the actions? So no 
adding and removing of actions

Perhaps the idea is then to prevent the caller from thinking: If i change the 
list i got, then the changes are visible to kactioncollection?

So what should i do? We cannot remove the const in KActionCollection. But i 
could remove it from KActionCategory. What is the right thing to do here?


> You really want QList<const QAction *>.

No i don't. I don't want to prevent the caller from changing the actions.

Michael Jansen


More information about the kde-core-devel mailing list