Qt信号映射
Qt signal mapping
我知道我们可以使用QSignalMapper来收集一组无参数信号,并使用与发送信号的对象相对应的整数、字符串或小部件参数重新发送它们。
但我们可以反过来做吗?例如,是否可以实现:
connect(control,startVehicle(0),vehcileList[0],startReceived());
connect(control,startVehicle(1),vehcileList[1],startReceived());
connect(control,startVehicle(2),vehcileList[2],startReceived());
而不是将来自控制的3个不同信号作为
startVehicle_1();
startVehicle_2();
startVehicle_3();
有一种更简单的方法:
connect(control, SIGNAL(startVehicle(int)), this, SLOT(startReceived(i)));
//in startReceived(i) slot
vehcileList[i]->startReceived();
相关文章:
- 删除一个线程上有数百万个字符串的大型哈希映射会影响另一个线程的性能
- Qt VTK交互风格的信号到小部件
- C++映射:具有自定义类的运算符[]不起作用(总是返回0)
- 将函数类成员映射到类本身内部
- 获取日期异步信号安全吗?如果在信号处理程序中使用,它会导致死锁吗
- 如何在 C# 中映射双 C 结构指针?
- 如何在C++中使用结构生成映射
- 使用std::函数映射对象方法
- 如何加载(或映射)文件部分的最大大小,但适合在Windows上的RAM
- C++映射分割错误(核心转储)
- 内联映射初始化的动态atexit析构函数崩溃
- 使用"std::unordereded_map"映射到"std::list"对象
- 如何从多映射中删除特定的重复项
- QlineEdit的信号映射问题
- 将一个对象的所有QT信号动态映射到一个插槽
- 如何编写包装类以将 Qt 信号映射到 C# 事件(通过 C++/CLI)
- Qt信号映射
- 将Qt基类信号映射到派生类中的槽
- Qt信号映射:编辑发射器对象
- 在c++中迭代映射时发出SIGSEGV信号