Neel Basu
Neel Basu

Reputation: 12904

Simulate QKeyEvent on Whatever Widget InFocus

I want to Simulate a QKeyEvent on the Currently Focused Widget. That widget Might not belong to My Application even the widget may not be an Qt Widget at all. I just want to Simulate a QKeyEvent On Whatever Widget In Focus now.

I've tried QApplication::postEvent(DG::Util::_desktopWidget, ev); Where DG::Util::_desktopWidget is the Primary Desktop Widget

QDesktopWidget* desktopWidget = new QDesktopWidget;
DG::Util::_desktopWidget = desktopWidget->screen(desktopWidget->primaryScreen());

But This doesn't work.

Upvotes: 1

Views: 299

Answers (1)

dimsuz
dimsuz

Reputation: 9207

With Qt you can only control widgets belonging to your app. Therefore you can't send QKeyEvent to non-Qt apps, or Qt apps which are different processes.

Upvotes: 1

Related Questions