Project directory structure

Dirk Hohndel dirk at hohndel.org
Tue Apr 2 11:35:02 PDT 2013


Thiago Macieira <thiago at macieira.org> writes:

> On terça-feira, 2 de abril de 2013 11.08.40, Dirk Hohndel wrote:
>> >> on a side note, if you are using the ui, the 'on_' methods do an
>> >> autoconnect, but while this is nice, if you change the name of the
>> >> variable to anything else, you will have broken but compilled code.
>> > 
>> > You don't rename widgets :-), and have run-time warnings anyway. But I
>> > don't mind -- if you prefer connecting signals by hand, that's OK with me.
>> > Anyone else has a different opinion here?
>> 
>> Magic names worry me. Can you explain how this works and what the
>> benefits are?
>
> The last line of the setupUi function that uic generates is:
>
>         QMetaObject::connectSlotsByName(<object var>);
>
> <http://qt-project.org/doc/qt-4.8/qmetaobject.html#connectSlotsByName> says:
>
> Searches recursively for all child objects of the given object, and connects 
> matching signals from them to slots of object that follow the following form:
>
>  void on_<object name>_<signal name>(<signal parameters>);
>
> Let's assume our object has a child object of type QPushButton with the object 
> name button1. The slot to catch the button's clicked() signal would be:
>
>  void on_button1_clicked();

Oh. That is actually really cool and useful.

Yes, renaming that obviously breaks things but I think this makes the
code cleaner and easier to browse...

While I'm clearly not the Qt expert here - I think I like this.

/D


More information about the subsurface mailing list