[Solved] Advice needed: Reload page on “F5”
[ It should be easy to solve, but I found no good starting point. ]
A reload in my application (i.e. a QWebView that loads a html page) already works because I can right-click on a page and select ‘Reload’. This seems to be enabled by default, I did not have to do anything to enable this.
What do I have to do, to achieve a reload by just pressing F5 as we know it from standard browsers? A hint to lead me into the right direction should be enough.
Thanks in advance!
11 replies
I would try to add a QAction together with a shortcut to the webview. You don’t need to subclass for this approach, just set the webview as the parent of the action.
Thanks so far!
Unfortunately it’s not working. Can you see what’s wrong? For ease of use, I put the code in the main.cpp, which I will not do in the end, but right now it makes it easier to trace my mistake…
- //extract from main.cpp:
- QWebView window;
- //[ ... some connects on window->page() and window->page()->mainFrame() ...]
- actionReload->setShortcut(keys_refresh);
- window.show();
- app.exec();
If I make right-click -> reload on my html page, the page gets reloaded, but not if I press F5.
[Edit: Even if I make s subclass and override the reload() slot, I see that the slot is not called. So either the action is not triggered, or the signal-slot connection is wrong]
you have forget to add action to WebView:@window.addAction(actionReload);@
Great, I was just wondering what kind of black magic binds the action to the window :-) Okay, that’s it. Thank you all (also thanks for the first answer, maybe I will also have to use the keyPressEvent() override for some other stuff, but for the reload it’s easier to use QActions.)
You must log in to post a reply. Not a member yet? Register here!





