Hi,
I have been trying to disable the right click "reload" menu on QWebView. After many failed attempts I tried the following code:
MyApplication::MyApplication(int argc, char *argv[]) :
{
installEventFilter(this);
}
{
if ( ( e
->type
() == QEvent::MouseButtonPress )||
( e
->type
() == QEvent::MouseButtonRelease )||
( e
->type
() == QEvent::MouseButtonDblClick ) ) {
return true;
//QMouseEvent* m = static_cast<QMouseEvent *>(e);
//int i = m->button();
//if ( i == Qt::RightButton)
//{
// return true;
//}
}
else if ( e
->type
() == QEvent::KeyPress ) {
if(k->key() == Qt::Key_F4)
{
quit();
return true;
}
}
}
MyApplication::MyApplication(int argc, char *argv[]) :
QApplication(argc, argv)
{
installEventFilter(this);
}
bool MyApplication::eventFilter(QObject *obj, QEvent *e)
{
if ( ( e->type() == QEvent::MouseButtonPress )||
( e->type() == QEvent::MouseButtonRelease )||
( e->type() == QEvent::MouseButtonDblClick ) )
{
return true;
//QMouseEvent* m = static_cast<QMouseEvent *>(e);
//int i = m->button();
//if ( i == Qt::RightButton)
//{
// return true;
//}
}
else if ( e->type() == QEvent::KeyPress )
{
QKeyEvent* k = static_cast<QKeyEvent *>(e);
if(k->key() == Qt::Key_F4)
{
quit();
return true;
}
}
return QApplication::eventFilter(obj, e);
}
To copy to clipboard, switch view to plain text mode
The strange thing is even though the mouse button events are disabled, still the "reload" menu shows up on the QWebView. I tired to inherit the QwebView and install my event filter also but with the same result. I think I missing something about this "reload" menu on QwebView.
Anyone, please let me know if you know of a way to disable the right click "reload" menu on QWebView. Thank you.
Sky.
Bookmarks