In QT 6.4.2, using QWindow::fromWinId and QWidget::createWindowContainer to embed Chrome. However, after embedding, it is found that Chrome cannot use keyboard data (but the mouse can). The same code, when embedding Firefox, works just fine. Does anyone know how to handle this? The code is as follows:
WId m_wid = (WId)FindWindow(L"Chrome_WidgetWin_1",L"百度一下,你就知道 - Google Chrome");//第一个参数xxx为调用的exe的类名;第二个xxx参数为调用的exe的标题名。
//WId m_wid = (WId)FindWindow(L"MozillaWindowClass",L"百度一下,你就知道 — Mozilla Firefox");//第一个参数xxx为调用的exe的类名;第二个xxx参数为调用的exe的标题名。
MouseTrackingWindow *M_WINDOW = (MouseTrackingWindow *)QWindow::fromWinId(m_wid);
M_WINDOW->setFlags(M_WINDOW->flags() | Qt::CustomizeWindowHint | Qt::WindowTitleHint);
MyWidget *childWidget =(MyWidget*)QWidget::createWindowContainer(M_WINDOW,this);//创建新的widget
ui->horizontalLayout->addWidget(childWidget);//将widget窗口加入到主界面布局中
childWidget->setFocusPolicy(Qt::StrongFocus);
childWidget->show();
embeded chrome connot input by keyboard
3