Hi,
It's possible to create/generate signals and slots in runtime (not compile time) ?
Regards,
Thanks
Hi,
It's possible to create/generate signals and slots in runtime (not compile time) ?
Regards,
Thanks
What does it mean "create/generate signals and slots in runtime" ?
Don't think so, but maybe we are not thinking about the same thing.
What is it that you are trying to achieve?
Cheers,
_
Well
Example I have an empty grilayout and receive a file to build ui by code.
So I create an new QCombobox() and set values.
Next I want to define a signal ex, changeCurrentIndex() and then generate a slot() dynamically, slot1(), slot2(), ...slotn()
Can I generate a callback slot for that ?
Cheers
You could have one slot and identify the sender using QObject::sender(), or have a dedicated receiver object for each row.
Cheers,
_
But I have previous in compile time define *.cpp code for that slot ?
Thanks
The actions performed by a slot, which is just another class function not some magical entity, have to be compiled into a code unit somewhere. You cannot do that at runtime for C++. You can, of course, connect existing signals and slots at runtime. If the range of behaviours to be performed by the slotn() functions is known then you can pre-build them and connect at runtime if they are needed.
Beyond that, it sounds like you want some sort of plugin that can provide a widget and associated processing logic. Qt has a plugin mechanism you can use.
Bookmarks