How do I create a custom slot in qt4 designer?

right click on the main window and select "change signals and slots" and add a new slot. It will appear in your signal slot editor.


This does seem to be possible in the version of Qt Designer 4.5.2, but it can't be done from the Signal/Slot Editor dock-widget in the main window.

This is what worked for me

  1. Switch to Edit Signals/Slots mode (F4)
  2. Drag and drop from the widget which is to emit the signal, to the widget which is to receive the signal.
  3. A Configure Connection dialog appears, showing the signals for the emitting widget, and the slots for the receiving widget. Click Edit... below the slots column on the right.
  4. A Signals/Slots of ReceivingWidget dialog appears. In here its is possible to click the plus icon beneath slots to add a new slot of any name.
  5. You can then go back and connect to your new slot in the Configure Connection dialog, or indeed in the Signal/Slot Editor dockwidget back in the main window.

Caveat: I'm using PyQt, and I've only tried to use slots added in this way from Python, not from C++, so your mileage may vary...


Unfortunately this is not possible in Qt4.

In Qt3 you could create custom slots which where then implemented in the ui.h file. However, Qt4 does not use this file so custom slots are not supported.

There is some discussion of this issue over on QtForum