void HoveringButtonsController::ForwardMouseClickEvent(float x, float y) { // To widgetspace float x_widgetspace = x*(float)this->width(); float y_widgetspace = y*(float)this->height(); QPoint pos(x_widgetspace,y_widgetspace); QMouseEvent e(QEvent::MouseButtonPress, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); QApplication::sendEvent(this, &e); // Iterate through buttons and check if they are pressed for(int i = 0; i< layout()->count();i++) { QLayoutItem* item = layout()->itemAt(i); QAbstractButton *button = dynamic_cast<QAbstractButton*>(item->widget()); if(button) { if(button->rect().contains(button->mapFromParent(pos))) { QMouseEvent e(QEvent::MouseButtonPress, pos - button->pos(),pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); QApplication::sendEvent(button, &e); } } } }