[Development] Proposal to change connectSlotsByName behavior

Olivier Goffart olivier at woboq.com
Fri Dec 4 08:39:55 CET 2015

On Thursday 3. December 2015 18:00:15 Thiago Macieira wrote:
> On Friday 04 December 2015 00:27:09 Olivier Goffart wrote:
> > I don't think it will break too many applications because anyone who was
> > relying on the order of instentiation for that has just its application
> > working out of pure luck. (And i'm pretty sure that your proposal is
> > always
> > the intended behaviour)
> Note that for widgets, the order is not pure luck. The order of children of
> a QWidget implies the tabbing order. Therefore, it is usually well-defined.

The tab order is set with QWidget::setTabOrder and does not depends on the 
order of the children.

> I don't mind changing the order, as long as there's a consensus in the
> mailing list.
> If we do decide to change the order, I have a follow-up question:
>  do we change it only in connectSlotsByName, or do we change
>  QObject::findChildren to reflect the new order?
> Right now, connectSlotsByName simply uses findChildren's order. If we decide
> to change the order in one but not the order, I'd like to hear a compelling
> reason why it's ok for them be different.

The documentation of findChild says:

    If there is more than one child matching the search, the most
    direct ancestor is returned. If there are several direct
    ancestors, it is undefined which one will be returned. In that
    case, findChildren() should be used.

This would be the expected behaviour, unfortunately, the implementation does 
not follow that.

FindChildren does not document the order.
So the order is then unspecified.  

Changing the order of findChildren would make the function slower.
Changing the order in connectSlotsByName would only make that function 
slightly slower.

I do not have strog opinion if the two functions must follow the same order.


Woboq - Qt services and support - http://woboq.com - http://code.woboq.org

More information about the Development mailing list