我正在使用 c++ Qt 库,我想做一些可以做到的事情:
connect(actionB11, SIGNAL(triggered()), this, SLOT(SetSomething(1, 1)));
connect(actionB12, SIGNAL(triggered()), this, SLOT(SetSomething(1, 2)));
connect(actionB21, SIGNAL(triggered()), this, SLOT(SetSomething(2, 1)));
connect(actionB22, SIGNAL(triggered()), this, SLOT(SetSomething(2, 2)));
上面的代码不起作用,因为 SIGNAL 函数必须具有与 SLOT 函数相同的数字和参数类型。
是否存在一种方法来做到这一点?我不想有大约 20 个函数作为 SetSomething11、SetSomething12 调用 SetSomething(1, 1) 等。