【问题标题】:Qt Signal-Slot interaction.Qt 信号槽交互。
【发布时间】:2010-06-28 10:14:28
【问题描述】:

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

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?

【问题讨论】:

标签: qt signals-slots


【解决方案1】:
QObject::connect(private_object, SIGNAL(someSignal()), this, SIGNAL(ParentSignal()));

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

【讨论】:

    猜你喜欢
    • 2012-02-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-11
    • 2021-02-12
    • 2017-02-23
    • 2011-10-29
    • 1970-01-01
    相关资源
    最近更新 更多