例:判断焦点在是否在某个QLineEdit上
QLineEdit *LineEdit;
QWidget *currentItem;
currentItem = QApplication::focusWidget();
if(currentItem != NULL){
if( currentItem->inherits("QLineEdit")){
LineEdit= qobject_cast<QLineEdit *>(currentItem);
LineEdit->setText("当前焦点在此");
}
}