c++qtqt4

Signals and Slots with Qtoolbutton


I have created a ToolButton with my qt designer and Im trying to connect it to a slot. I wrote this

connect(ui->toolButton_addfiles, SIGNAL(triggered()), this, SLOT(changeDirectory()));

Im able to run the program but when I press the button I see the following log into my qt Application Output :

   Object::connect: No such signal QToolButton::triggered() in ../RightDoneIt/rightdoneit.cpp:10
    Object::connect:  (sender name:   'toolButton_addfiles')
    Object::connect:  (receiver name: 'RightDoneIt')

How can I make this connection work ?


Solution

  • As the error says, there's no signal triggered() but triggered(QAction*) in the QToolButton.

    Edit In the connect function you must have the signal signature like triggered(QAction*) since QToolButton class has no signal triggered() (with no parameter) declared