在Qt C ++中同时调用插槽

时间:2019-01-20 17:00:31

标签: signals slots

我想在Qt C ++中同时调用多个插槽。

var animals = [
  "Cat",
  "Dog",
  "Elephant",
  "Wolf",
]

var choosenvalue = 1;

console.log(animals[choosenvalue]);

上面有插槽。
一个向前,一个向后,一个向左转,一个向右转。
每个插槽都连接有不同的按钮。
我要保持向前或向后按下pushButons,同时要调用rightPressed()或leftPressed()。
在我调用rightPressed()或leftPressed时,我不希望ForwardPressed()或BackwardPressed()停止,反之亦然。

QObject::connect(widget.pushButton_Forward, SIGNAL(clicked()), this, SLOT(forwardPressed()));; QObject::connect(widget.pushButton_Backward, SIGNAL(clicked()), this, SLOT(backwardPressed())); QObject::connect(widget.pushButton_Left, SIGNAL(clicked()), this, SLOT(leftPressed())); QObject::connect(widget.pushButton_Right, SIGNAL(clicked()), this, SLOT(rightPressed()));
不停止任何一个。

有解决方案吗?

0 个答案:

没有答案