Search code examples
qtsignals-slots

Qt Signal-Slot interaction.


Whan I want to use a signal of a private object in order to arise a signal of its parent object I do the following:

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();
}

Is there any way to do this process directly, that is, without ParentSlot?


Solution

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

    See http://doc.qt.io/qt-5/qobject.html#connect