qtopia让窗体区别触摸屏短按与长按

qtopia让窗体区别触摸屏短按与长按

板子:君益兴helper2416     qtopia2.2     作者:帅得不敢出门   c++哈哈堂:31843264

   在窗体构造函数中

right_pressed = false; // 类成员
    // Enable stylus press events
    QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );

然后

void xx::mouseReleaseEvent( QMouseEvent* e )
{
    // If left button clicked, emit selected
    if( !right_pressed && e->button() == Qt::LeftButton ) emit selected();
}

void xx::mousePressEvent( QMouseEvent* e )
{
    right_pressed = false;
    // If right button pressed, emit held
    if( e->button() == Qt::RightButton ) {
        right_pressed = true;
        emit held( e->globalPos() );
    }
}
这个例子是短按发送selected() 信号,   长按发送held(QPoint)信号.


你可能感兴趣的:(qtopia让窗体区别触摸屏短按与长按)