Qt信号 - 插槽交互。

时间:2010-06-28 10:14:28

标签: qt signals-slots

Whan我想使用私有对象的信号来产生其父对象的信号我执行以下操作:

1. I create a signal and a slot (named, let's say, ParentSignal, ParentSlot)
2. connect(private_objcet, SIGNAL(someSignal()), this, SLOT(ParentSlot()));
3. and define parent slot like this:
void ParentSlot()
{
    emit ParentSignal();
}

有没有办法直接执行此过程,即没有ParentSlot?

1 个答案:

答案 0 :(得分:3)

QObject::connect(private_object, SIGNAL(someSignal()), this, SIGNAL(ParentSignal()));

请参阅http://doc.qt.io/qt-5/qobject.html#connect