QObject::connect(button1, SIGNAL(clicked()), text, SLOT(setNum()));
如果connect在calculator中,应该这么写:
Calculator:xxxx()
{
QObject::connect(button1, SIGNAL(clicked()), this, SLOT(setNum()));
}
如果在其他类中,应该这么写:
OtherClass:xxxx()
{
QObject::connect(button1, SIGNAL(clicked()), calculator, SLOT(setNum()));
}
因为你的slot是在Calculator中定义的,不应该连接到text