[Interest] Keyboard focus with QWidget::createWindowContainer() not working

Wilhelm wilhelm.meier at fh-kl.de
Fri Dec 19 10:33:43 CET 2014


Hi all,

the following example code looks for the WId of a running kate-process
and embeds the window into my own application. Thats all fine:
rendering, resizing, mouse-events (e.g. menus of kate) are all working.

The only problem ist keyboard-focus: kate doesn't get the keystrokes!

I tried various thing like grabKeyboard() etc. (see below) but without
success.

Any hints!

---

WId kateId = WindowSystem::findWindow(QRegularExpression("[Kk]ate"));

qDebug() << "kate:" << kateId;

if (kateId) {
    QWindow* kateWindow = QWindow::fromWinId(kateId);
    kateWindow->requestActivate();
    qDebug() << "kate:" << kateWindow;
    QWidget* kateWidget = QWidget::createWindowContainer(kateWindow, this);

    kateWidget->setFocus();
    kateWidget->grabKeyboard();

    setCentralWidget(kateWidget);
}

-- 
Wilhelm
w.meier at unix.net



More information about the Interest mailing list