[Solved] No such signal - My own class
-
Dear all,
I created my own PushButton to receive a signal when my button get focus. Please see code below:
@
class MyPushButton : public QPushButton
{
Q_OBJECTpublic:
MyPushButton(QWidget *parent = 0);signals:
void getFocus();protected:
void focusInEvent (QFocusEvent * event);};
MyPushButton::MyPushButton(QWidget *parent) :
QPushButton(parent)
{
}void MyPushButton::focusInEvent (QFocusEvent * event)
{
emit getFocus();
QPushButton::focusInEvent(event);
}@
And in the main application I connect the signal to the slot.
@
connect(ui->btn1, SIGNAL(gotFocus()), this, SLOT(gotFocus1()));
@When I start the application, I receive the following message:
@
Object::connect: No such signal MyPushButton::gotFocus() in ../page1.cpp:26
Object::connect: (sender name: 'btn1')
Object::connect: (receiver name 'Page1')
@So, what is wrong in my code? Any ideas?
I promoted my QPushButton to MyPushButton.
Thanks a lot.
-
-
[quote author="iunknwn" date="1289581834"]Good Programming Practice: If you are using Visual Studio, let intellisense type the signal out as
Once you get it filled, delete "sender->". This way you can never get the signal name typed incorrectly.
[/quote]or use QtCreator, it shows available signals when you write code.