qt中信号和槽的总结
2007-09-28 12:11
525 查看
connect (sender,SIGNAL(signal),receiver,SLOT(slot));
1,一个信号可以被连接到多个槽。
connect(slider, SIGNAL(valueChanged(int)),
spinBox, SLOT(setValue(int)));
connect(slider, SIGNAL(valueChanged(int)),
this, SLOT(updateStatusBarIndicator(int)));
当这个信号被发射的时候,这些槽会一个一个的以任意的顺序被调用。 When the signal is emitted, the slots are called one after the other, in an arbitrary order.
2,多个信号可以被连接到一个槽。
connect(lcd, SIGNAL(overflow()),
this, SLOT(handleMathError()));
connect(calculator, SIGNAL(divisionByZero()),
this, SLOT(handleMathError()));
只要其中的一个信号被发射,这个槽就会被调用。When either signal is emitted, the slot is called.
3,一个信号可以被连接到另外一个信号。
connect(lineEdit, SIGNAL(textChanged(const QString &)),
this, SIGNAL(updateRecord(const QString &)));
当第一个信号被发射时,第二个信号也会被发射,除此之外,信号到信号的连接和信号到槽的连接是难以区分的。When the first signal is emitted, the second signal is emitted as well. Apart from that, signal–signal connections are indistinguishable from signal–slot connections.
4,连接可以被断开。
disconnect(lcd, SIGNAL(overflow()),
this, SLOT(handleMathError()));
This is rarely needed, because Qt automatically removes all connections involving an object when that object is deleted.
When connecting a signal to a slot (or to another signal), they must both have the same parameter types in the same order:
connect(ftp, SIGNAL(rawCommandReply(int, const QString &)),
this, SLOT(processReply(int, const QString &)));
Exceptionally, if a signal has more parameters than the slot it is connected to, the additional parameters are simply ignored:
connect(ftp, SIGNAL(rawCommandReply(int, const QString &)),
this, SLOT(checkErrorCode(int)));
If the parameter types are incompatible, or if the signal or the slot doesn't exist, Qt will issue a warning at run-time. Similarly, Qt will give a warning if parameter names are included in the signal or slot signatures.
1,一个信号可以被连接到多个槽。
connect(slider, SIGNAL(valueChanged(int)),
spinBox, SLOT(setValue(int)));
connect(slider, SIGNAL(valueChanged(int)),
this, SLOT(updateStatusBarIndicator(int)));
当这个信号被发射的时候,这些槽会一个一个的以任意的顺序被调用。 When the signal is emitted, the slots are called one after the other, in an arbitrary order.
2,多个信号可以被连接到一个槽。
connect(lcd, SIGNAL(overflow()),
this, SLOT(handleMathError()));
connect(calculator, SIGNAL(divisionByZero()),
this, SLOT(handleMathError()));
只要其中的一个信号被发射,这个槽就会被调用。When either signal is emitted, the slot is called.
3,一个信号可以被连接到另外一个信号。
connect(lineEdit, SIGNAL(textChanged(const QString &)),
this, SIGNAL(updateRecord(const QString &)));
当第一个信号被发射时,第二个信号也会被发射,除此之外,信号到信号的连接和信号到槽的连接是难以区分的。When the first signal is emitted, the second signal is emitted as well. Apart from that, signal–signal connections are indistinguishable from signal–slot connections.
4,连接可以被断开。
disconnect(lcd, SIGNAL(overflow()),
this, SLOT(handleMathError()));
This is rarely needed, because Qt automatically removes all connections involving an object when that object is deleted.
When connecting a signal to a slot (or to another signal), they must both have the same parameter types in the same order:
connect(ftp, SIGNAL(rawCommandReply(int, const QString &)),
this, SLOT(processReply(int, const QString &)));
Exceptionally, if a signal has more parameters than the slot it is connected to, the additional parameters are simply ignored:
connect(ftp, SIGNAL(rawCommandReply(int, const QString &)),
this, SLOT(checkErrorCode(int)));
If the parameter types are incompatible, or if the signal or the slot doesn't exist, Qt will issue a warning at run-time. Similarly, Qt will give a warning if parameter names are included in the signal or slot signatures.
相关文章推荐
- Qt 信号槽总结
- QT信号和槽总结
- Qt信号和槽的个人总结
- QT总结之信号与槽
- Qt中消息信号与事件的总结
- 初学Qt:QLineEdit类信号总结
- Qt 的几个核心机制总结之 信号与槽
- Qt 的几个核心机制总结之 信号与槽
- Qt总结1——槽与信号
- Qt信号和槽的个人总结
- Qt信号槽分析总结
- Qt学习总结(C鱼)之信号与槽01
- QT 信号与槽的参数转存(转载)
- 关于在Qt里让程序休眠一段时间的方法总结
- 初学Qt:信号与槽
- qt4 消息映射--信号 槽
- qt 信号与槽
- 基于Qt的函数对象(泛化仿函数)设计,可在线程中运行并通过信号返回QVariant
- 初学Qt之--带参数的信号和槽的实现(入门级)
- QT跨线程的信号与槽