Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4462407
  • 博文数量: 356
  • 博客积分: 10458
  • 博客等级: 上将
  • 技术积分: 4734
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-24 14:59
文章分类

全部博文(356)

文章存档

2020年(17)

2019年(9)

2018年(26)

2017年(5)

2016年(11)

2015年(20)

2014年(2)

2013年(17)

2012年(15)

2011年(4)

2010年(7)

2009年(14)

2008年(209)

分类: 嵌入式

2013-01-16 10:07:28

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

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

   在窗体构造函数中

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

然后

  1. void xx::mouseReleaseEvent( QMouseEvent* e )  
  2. {  
  3.     // If left button clicked, emit selected  
  4.     if( !right_pressed && e->button() == Qt::LeftButton ) emit selected();  
  5. }  
  6.   
  7. void xx::mousePressEvent( QMouseEvent* e )  
  8. {  
  9.     right_pressed = false;  
  10.     // If right button pressed, emit held  
  11.     if( e->button() == Qt::RightButton ) {  
  12.         right_pressed = true;  
  13.         emit held( e->globalPos() );  
  14.     }  
  15. }  
这个例子是短按发送selected() 信号,   长按发送held(QPoint)信号.
阅读(1707) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~