[Solved] Connecting a QPushButton and a function
I'm creating a QPushButton, putting it on the form and then connecting it so that when it gets clicked, a function is called. This is what I have in the .h file:
And this is what's in the .cpp file:
manAutoButton = new QPushButton(this);
connect(manAutoButton, SIGNAL(clicked()), this, SLOT(on_manAutoButton_clicked()));
When the app runs, everything is fine. The function gets called whenever I click the manAutoButton. The only thing is that I get the following message in the run window: "QMetaObject::connectSlotsByName: No matching signal for on_manAutoButton_clicked()". What am I doing wrong?
EDIT: moved to General, peppe
HuXiKa last edited by
You have to create the on_manAutoButton_clicked() function in your .cpp file.
Yes, it was already in there. For completeness, this is it:
if(mode == Auto)
mode = Manual;
RazrFalcon last edited by
Try to remove on_ from slot name.
connect(manAutoButton, SIGNAL(clicked()), this, SLOT(manAutoButton_clicked()));
Thanks - that did it. I guess the buttons that are placed on Designer UI forms are automatically connected to the on_buttonname_clicked functions, but creating your own functions in that format creates some confusion.