[SOLVED] Simulate input for a QMainWindow
General and Desktop
3
Posts
2
Posters
1.4k
Views
1
Watching
-
Hello,
I would like to simulate mouse/key input for a QMainWindow.
I was trying with this:void MainWindow::SltButtonClicked() { QPointF pos(ui.pushButton_2->pos()); QObject* rec = this; // ui.centralWidget // ui.pushButton_2 // QApplication::instance() QApplication::postEvent(rec, new QMouseEvent(QEvent::MouseButtonPress, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier)); QApplication::postEvent(rec, new QMouseEvent(QEvent::MouseButtonRelease, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier));
It works only if the receiver is ui.pushButton_2 (and pos is 0, 0).
But I want to send the click to the QMainWindow and decide by pos which widget will receive the click.How is it possible?
Thank you very much!