-
void tab_simulate()
-
{
-
QKeyEvent event(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier);
-
QApplication::sendEvent(this, &event);
-
-
QWidget* widget = this->focusWidget();
-
QPushButton* pushbutton = dynamic_cast<QPushButton*>(widget);
-
while (pushbutton == 0)
-
{
-
QKeyEvent event(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier);
-
QApplication::sendEvent(this, &event);
-
widget = this->focusWidget();
-
pushbutton = dynamic_cast<QPushButton*>(widget);
-
}
-
}
把它作为一个槽函数,用一个按钮的click()信号来和它connect起来即可
阅读(1106) | 评论(0) | 转发(0) |