Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to connect QActions to SLOTS using qt designer

I have created a nice looking toolbar using qt Designer and populated it with some actions.
I tried to connect the actions to slots visually from qt designer by clicking edit> signals and slots. This DID NOT WORK because i could not find any QAction signals.

Question.

Is there a way to connect the QAction SIGNAL(triggered()) to my slots within QT designer? Please help.
PS: I am currently being forced to connect through code:

QObject::connect(myAction, SIGNAL(triggered()),this, SLOT(myActionWasTriggered()))

but ia am lazy and i wish to connect using qt designer.

like image 417
Dr Deo Avatar asked Jan 12 '11 16:01

Dr Deo


1 Answers

There's "Signal/Slot Editor" docked panel (Toggled with View->Signal/Slot Editor). You can connect your actions there. You may also need to add your custom slots via the "Change signals/slots" form context menu.

To save yourself some work, use the auto-connection feature (see QMetaObject::connectSlotsByName). Basically, all slots named with a specific pattern of on_objectName_signalName will be auto-connected.

like image 59
Nikita Nemkin Avatar answered Nov 06 '22 01:11

Nikita Nemkin