0

考虑我有两个窗口:window1如下window2所示

------------------------------
| x | This is the window1    |
|----------------------------|
|                            |
|    This window contains    |
|   a webview that has       |
|   transparent background. -|----------------|
|           | x |            | This is window2|
|            - - - - - - - --|----------------|
|           |If I click HERE |                |
------------------------------                |
            | I want to activate window2.     |
            |                                 |
            |                                 |
            |                                 |
            -----------------------------------

window1将 HTML 文件加载到 aQWebView中,并且有一个透明区域,如此处所述

现在的问题是,当我单击透明区域时,window1(在这种情况下window2)下面的窗口没有被激活。这很正常,因为有一个具有透明背景的 HTML 文档。

我认为正确的方法是在 C++ 中创建一个函数,该函数将模拟对已激活窗口已知坐标的单击

我怎样才能在 Qt 中做到这一点?

4

1 回答 1

0

我想你可以重新实现虚拟 QWidget 功能:

void QWidget::mousePressEvent( QMouseEvent * event )

并指定“可点击矩形”:

void MyWebView::mousePressEvent( QMouseEvent * event ) {
   // Set this a class variable
   QRect clickableArea = QRect( int x, int y, int width, int height);
   if( clickableArea->contains(event->pos()) ) {
       // Activate window2
   }
}
于 2013-12-20T10:48:04.643 回答