In QT Creator, design mode, I right-click on a widget and select "Go to slot" and it creates a slot function for one of the widget's signals.
I would have thought that this would have generated a connect()
function to create this connection, however, I can't find anything like that in any of the source code.
Where is the actual code that connects the widget's signal to the slot function?
thanks
If you're using QtCreator's Designer, one of the outputs from this is a .ui
file
Qt Designer ui files are an XML representation of your form's widget tree, and are processed by uic
, the "User Interface Compiler"
One of the features provided by Qt's ui format is AutoConnect.
uic
automatically generates code in the form's setupUi()
function to connect your signals and slots.
The way it works is as follows:
Your slots must conform to the following format:
void on_<object-name>_<signal-name>(<signal-parameters>);
where object-name
is the name of the object which emits the signal this slot is for.
Later, uic
then generates code which calls QMetaObject::connectSlotsByName(this);
Using Qt's reflection system, the QObject
which has objectName()
=object-name
is found, and it's signal is connected to your slot.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With