主题 : 在qt觸控沒有beep出現 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 27334
精华: 0
发帖: 41
金钱: 205 两
威望: 41 点
综合积分: 82 分
注册时间: 2010-08-24
最后登录: 2018-07-15
楼主  发表于: 2011-01-26 09:31

 在qt觸控沒有beep出現

在linux2.6.32.2下使用micro 2440
在觸控面板下要產生beep除了用
QApplication::beep(); //沒有反應
是否有其他方法,
使用keyEvent,mouseEvent,也要逐一判斷.
如果使用eventfilter,則每一個frame,object都要加入installevent
一旦object多了,就要加入很多次的installevent
不知道有沒有單一指令,在每一個frame或object,只要touch就能產生beep.
beep是控制 /dev/pwm產生的.
级别: 新手上路
UID: 27334
精华: 0
发帖: 41
金钱: 205 两
威望: 41 点
综合积分: 82 分
注册时间: 2010-08-24
最后登录: 2018-07-15
1楼  发表于: 2011-01-27 14:32
目前先以以下方式處理

if(event->type() == QEvent::MouseButtonPress)
    Beep();
else if (event->type() == QEvent::UpdateLater)
    Beep();
else if(event->type() == QEvent::Enter)
    Beep();

Beep則以以下方式處理
   static int fd = -1;
      int freq = 550;
      int ret;

      if (fd < 0) fd = open("/dev/pwm", 0);// open pwm_buzzer device
      while( freq>0 )
      { ret = ioctl(fd, 1, 1190000/4000);// set the frequency of the buzzer
        freq=freq--;
      }
      ret = ioctl(fd, 0); // stop the buzzer
      if (fd >= 0) { ioctl(fd, 0); close(fd); fd = -1; } //close buzzer

暫時可用!
如果有更好或正確的處理方式,麻煩能提供!
感謝