i have a problem creating QPushButton with signal and slot. First i was created a class where is slot :
class A : public QWidget{
public slots:
void handleButton();
};
There is my handleButton function : in .cpp
void A::handleButton(int row, int col){
m_button->setText("Example");
// resize button
m_button->resize(100,100);
}
Then i want to connect button.
QObject::connect(m_button, SIGNAL(clicked()),qApp, SLOT(handleButton()));
But i got an error when i start application : "No such slot" Any one can help me?
Make sure that qApp
is an object of class A
(i.e. where your slot is defined).
That said, the signatures are wrong: a signal links to a slot only if the signature match
http://qt-project.org/doc/qt-4.8/signalsandslots.html
The signals and slots mechanism is type safe: The signature of a signal must match the signature of the receiving slot.
And your slot hasn't the right signature:
http://qt-project.org/doc/qt-4.8/qabstractbutton.html#clicked
void QAbstractButton::clicked ( bool checked = false ) [signal]