How to connect signal to slot in Qt Designer?
It seems that there are 2 ways to connect signal to slot with Qt designer:
- edit->edit signals/slot and the click on widget.
- right click on widget -> and choose "go to slot..."
I am not sure what is the difference between these 2 options.
IIRC, number one allows you to connect two compatible signal and slot from widgets directly e.g. a QSpinBox with a QSlider, and number two will send you to the code editor where you'll implement whatever your application needs to do in that slot.
As I understand, both method use the signal-slot method (not callbacks or event) , Right ?
Another think if I may please ask, I tried to see the resulted moc code, but the moc files are missing in project (although they exist in path), Is there some way to include them in project (or shouldn't we do that) ?
Don't include them in your project.
These files are generated from your code.
You can find them in the build folder. They are worth a look if you'd like to understand the internals however I'd recommend reading the woboq blog which has very good articles on several aspects of Qt.
@ranshalit hello. I'd recommend not to use the signal/slot connection via the designer, it's better to write them yourself so you could get the hang how the signal/slot mechanism works, because in the future you will use them a lot.