QT信号槽问题
我在 QGridLayout 中有 QLineEdits 矩阵。我想在 QLineEdits 的文本之一发生更改时发出信号。我可以将信号连接到插槽,但无法知道哪个 QLineEdit 已更改。我想发送 QLineEdit 的行列号,但根据诺基亚论坛有将变量传递到插槽的情况。
我想知道你们有什么建议吗?
一种方法是将旧值与新值进行比较,但这效率很低。
谢谢你!
I have matrix of QLineEdits in a QGridLayout. I want to signal when one of QLineEdits' text changes. I can connect the signal to a slot but there is no way of knowing which QLineEdit was changed. I would like to send the row column number of QLineEdit but there is pass variables to a slot according nokia fourms.
I was wondering if any of you have any suggestions?
One way to do it is to compare old values to new values, but this is inefficient.
Thank You!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 QSignalMapper 类。这将使您能够执行您所要求的操作。
另请参阅高级信号和时隙使用了解更多信息和一些示例。
You could use the QSignalMapper class. This would allow you to do what you're asking.
See also Advanced Signals and Slots Usage for more info and some examples.
QObject::sender()
编辑:请注意那里的 QSignalMapper 参考。
QObject::sender()
Edit: note the QSignalMapper reference there as well.