[Solved] QWebPage::WebAction add own Action to context menu
-
wrote on 25 Aug 2011, 13:15 last edited by
Hallo everyone,
does anybody know how do I add custom QAction to Standart QWebPage context menu or change attributes of standard one?I actually need to disable "Go Back" and "Reload" actions. + Enable/or add my own "Sellect All"(and reconnect it to my own slot, because of buggy behavior of standard action if enabled with setContentEditable(true))....
@
QWebView view = new QWebView();
// This gives Segnebtation fault
QAction test = view->page()->action(QWebPage::SelectAll)->menu()->addAction("Sellect All");//this does nothing at all
QAction test = view->page()->action(QWebPage::SelectAll);
test->setEnabled(true);
test->setVisible(true);connect( .... etc...
@ -
wrote on 25 Aug 2011, 14:09 last edited by
Just override QWebView::contextMenuEvent. In there, you can check if the menu is swallowed by the QWebPage (swallowContextMenuEvent), get the default one from the page (QWebPage::createStandardContextMenu), modify it, and/or exec the one you want.
-
wrote on 25 Aug 2011, 14:28 last edited by
Thank you, peppe!
I will try that... -
wrote on 26 Aug 2011, 07:40 last edited by
Wroks perfect! Thanks!
1/4