Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7565150
  • 博文数量: 961
  • 博客积分: 15795
  • 博客等级: 上将
  • 技术积分: 16612
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-07 14:23
文章分类

全部博文(961)

文章存档

2016年(1)

2015年(61)

2014年(41)

2013年(51)

2012年(235)

2011年(391)

2010年(181)

分类: 嵌入式

2013-12-05 11:40:01


点击(此处)折叠或打开

  1. void tab_simulate()
  2. {
  3.     QKeyEvent event(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier);
  4.     QApplication::sendEvent(this, &event);

  5.     QWidget* widget = this->focusWidget();
  6.     QPushButton* pushbutton = dynamic_cast<QPushButton*>(widget);
  7.     while (pushbutton == 0)
  8.     {
  9.         QKeyEvent event(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier);
  10.         QApplication::sendEvent(this, &event);
  11.         widget = this->focusWidget();
  12.         pushbutton = dynamic_cast<QPushButton*>(widget);
  13.     }
  14. }
把它作为一个槽函数,用一个按钮的click()信号来和它connect起来即可
阅读(1061) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~