(一)
class SignalClass
{
singals:
MySignal(QString text);// 如果槽在另一线程,尽量不要用引用投递
}
class SlotClass
{
slots:
MySlot(const QString& text);
}
SignalClass signalObj;
SlotClass slotObj;
// 如果信号和槽不在同一线程,视需要采用Qt::BlockingQueuedConnection
connect(&signalObj, SIGNAL(MySignal(QString)), this, SLOT(MySlot(QString)));
不要写为connect(&signalObj, SIGNAL(SignalClass::MySignal(QString)), this, SLOT(SlotClass::MySlot(QString)))或connect(&signalObj, SIGNAL(MySignal(QString)), this, SLOT(MySlot(QString&))); 如果写成这样会报no such signal或no such slot错误。