#include #include #include #include int main(int argc, char *argv[]) { QApplication a(argc, argv); QWidget w1; w1.setGeometry(0,0, 400, 300); QPushButton pb1(&w1); pb1.setGeometry(100,50, 100, 50); w1.show(); QWidget *target = 0; QPoint pt; pt.setX(110); pt.setY(60); if (QWidget *topLevel = qApp->topLevelAt(pt)) { QWidget *child = topLevel->childAt(topLevel->mapFromGlobal(pt)); target = child ? child : topLevel; } qDebug() << target; return a.exec(); }