1
我想不同的信号连接到像这样相同的插槽:如何将不同的信号连接到QT上的同一个插槽?
connect(thread_notification,SIGNAL(signal1()),SIGNAL(signal2()),this,SLOT(slot()));
这可能吗?
我想不同的信号连接到像这样相同的插槽:如何将不同的信号连接到QT上的同一个插槽?
connect(thread_notification,SIGNAL(signal1()),SIGNAL(signal2()),this,SLOT(slot()));
这可能吗?
是的,这是可能的。 您可以通过简单的做到这一点写一个连接语句为每个信号要发送到您的插槽,如:
connect(thread_notification, SIGNAL(signal1()), this, SLOT(slot()));
connect(thread_notification, SIGNAL(signal2()), this, SLOT(slot()));
...
connect(thread_notification, SIGNAL(signalN()), this, SLOT(slot()));
的另一种方式,你可以遵循,尤其是在信号发件人是数组,列表,或在一般而言,对象的容器是使用QSignalMapper,但它取决于谁发送和发送什么信号。你可以在这里找到一个explenation http://doc.qt.io/qt-4.8/qsignalmapper.html