考虑我有两个窗口: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文件加载到QWebView
,并且有一个透明区域like described here。
现在的问题是,当我点击透明区域时,window1
下面的窗口(在这种情况下为window2
)未激活。这是正常的,因为有一个透明背景的HTML文档。
我认为正确的方法是在C ++中创建一个函数来模拟点击已激活窗口下的已知坐标 。
我如何在Qt中执行此操作?
答案 0 :(得分: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
}
}