Important: Please read the Qt Code of Conduct -

How to connect signal to slot in Qt Designer?

  • Hello,

    It seems that there are 2 ways to connect signal to slot with Qt designer:

    1. edit->edit signals/slot and the click on widget.
    2. right click on widget -> and choose "go to slot..."

    I am not sure what is the difference between these 2 options.

    Thank you,

  • Lifetime Qt Champion


    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.

  • Hi SGaist,

    Thank you!

    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) ?


  • Lifetime Qt Champion

    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.

Log in to reply