Nominate our 2022 Qt Champions!

New to Qt Creator..question about custom slot code generation

  • Hi All,
    So I've been experimenting with Qt Creator, and started with created a dialog based application. Switched to designer mode, added a push button. Switched to signal/slot editor, and connected the signal clicked() to a custom slot called CustomButtonHandler(). I'm used to other IDEs filling in some declaration/definition (skeleton) code for me. Is it normal that Qt creator does not add "CustomButtonHandler()" to the slot section of the Dialog class declaration, and by the same token, not create the definition of the method in the cpp file? Is this meant to be all done manually?


  • Qt Champions 2017

    It does not do that. You need to add your custom slot code to dialog class.

  • You basically have two types of signals/slots that can be automatically added by creator to your code:

    1. buttons, widgets, etc: place the button/widget/etc on your form, right-click your button/widget/etc, select "Got to slot...", then select the action you want to implement. Once you selected an action the signal/slot code is automatically inserted to your code
    2. Menu items: Add the menu item you want to your window, and at the bottom of Creator's Design mode screen select the "Action Editor" tab. You will now see your menu item listed in the list of actions, right click the action and select "Go to slot...". Again, Creator will automatically insert the code template for that action in your code

Log in to reply