QtWebkit 解析事件调度程序
我最近在玩 QtWebkit,我想知道是否可以解析 QWebView 中显示的负责事件的元素,例如 MouseEvent。
我在 WebView 对象上安装了一个 EventFilter 函数,其函数如下:
bool WebKitManager::eventFilter(QObject *obj, QEvent *event)
{
if(event->type() == QEvent::MouseButtonRelease)
{
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
if(mouseEvent->button() == Qt::LeftButton)
{
// what now?!
}
}
return false;
}
有没有办法获取对 QWebView 中显示的单击元素的引用?据我所知,传递的 QObject 等于 WebView 对象,并且事件似乎没有引用其调度程序。
由于我距离成为 C++ 专业人士还很远,我真诚地希望我错过了一些东西,你们可以帮助我:)
提前致谢 蒂莫
i'm playing around with QtWebkit lately and i was wondering if it is possible to resolve the element displayed in the QWebView which is responsible for an event, e.g. a MouseEvent.
I've installed an EventFilter function at the WebView Object with a function like this:
bool WebKitManager::eventFilter(QObject *obj, QEvent *event)
{
if(event->type() == QEvent::MouseButtonRelease)
{
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
if(mouseEvent->button() == Qt::LeftButton)
{
// what now?!
}
}
return false;
}
Is there any way to get a reference to the clicked element that is displayed in the QWebView? As far as i can tell, the passed QObject equals the WebView object and the event doesn't seem to hold reference to its dispatcher.
Since i'm far away from beeing a c++ professional i sincerely hope i missed something and you guys can help me out :)
Thanks in advance
Timo
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信你可以做的是:
下面是一个示例:
希望这有帮助,问候
I believe what you could do is:
Below is an example:
hope this helps, regards
使用
qobject_cast
而不是dynamic_cast
。Use
qobject_cast
instead ofdynamic_cast
.