最近在项目中实现了一个按钮长按之后连续动作的功能,分享给大家,对于触摸屏操作的同学来说还是很有用的。
功能函数如下:
主要注意的事项是,设置autoRepeat属性后,要设置动作间隔时间,否则无法生效的。
void TechSettingPanel::setRepeatMove( bool movable )
{
ui->btnCoordR->setAutoRepeat(movable);
ui->btnCoordR_2->setAutoRepeat(movable);
ui->btnCoordX->setAutoRepeat(movable);
ui->btnCoordX_2->setAutoRepeat(movable);
ui->btnCoordY->setAutoRepeat(movable);
ui->btnCoordY_2->setAutoRepeat(movable);
ui->btnCoordZ->setAutoRepeat(movable);
ui->btnCoordZ_2->setAutoRepeat(movable);
if( movable )
{
ui->btnCoordR->setAutoRepeatInterval(RepeatInternal);
ui->btnCoordR_2->setAutoRepeatInterval(RepeatInternal);